r_task.h

Go to the documentation of this file.
00001 ///
00002 /// \file       r_task.h
00003 ///             Record parsing class for the task database.
00004 ///
00005 
00006 /*
00007     Copyright (C) 2005-2010, Net Direct Inc. (http://www.netdirect.ca/)
00008     Copyright (C) 2007, Brian Edginton
00009 
00010     This program is free software; you can redistribute it and/or modify
00011     it under the terms of the GNU General Public License as published by
00012     the Free Software Foundation; either version 2 of the License, or
00013     (at your option) any later version.
00014 
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018 
00019     See the GNU General Public License in the COPYING file at the
00020     root directory of this project for more details.
00021 */
00022 
00023 #ifndef __BARRY_RECORD_TASK_H__
00024 #define __BARRY_RECORD_TASK_H__
00025 
00026 #include "dll.h"
00027 #include "record.h"
00028 #include "r_recur_base.h"
00029 #include <vector>
00030 #include <string>
00031 #include <stdint.h>
00032 
00033 namespace Barry {
00034 
00035 // forward declarations
00036 class IConverter;
00037 
00038 class BXEXPORT Task : public RecurBase
00039 {
00040 public:
00041         typedef std::vector<UnknownField>               UnknownsType;
00042 
00043         uint8_t RecType;
00044         uint32_t RecordId;
00045 
00046         std::string Summary;
00047         std::string Notes;
00048         CategoryList Categories;
00049         std::string UID;
00050 
00051         time_t StartTime;
00052         time_t DueTime;
00053         time_t AlarmTime;
00054         unsigned short TimeZoneCode;
00055         bool TimeZoneValid;             // true if the record contained a
00056                                         // time zone code
00057 
00058         enum AlarmFlagType
00059         {
00060                 Date = 1,
00061                 Relative
00062         };
00063         AlarmFlagType AlarmType;
00064 
00065         enum PriorityFlagType
00066         {
00067                 High = 0,
00068                 Normal,
00069                 Low
00070         };
00071         PriorityFlagType PriorityFlag;
00072 
00073         enum StatusFlagType
00074         {
00075                 NotStarted = 0,
00076                 InProgress,
00077                 Completed,
00078                 Waiting,
00079                 Deferred
00080         };
00081         StatusFlagType StatusFlag;
00082 
00083         bool DueDateFlag;       // true if due date is set
00084 
00085         // unknown
00086         UnknownsType Unknowns;
00087 
00088 protected:
00089         static AlarmFlagType AlarmProto2Rec(uint8_t a);
00090         static uint8_t AlarmRec2Proto(AlarmFlagType a);
00091 
00092         static PriorityFlagType PriorityProto2Rec(uint8_t p);
00093         static uint8_t PriorityRec2Proto(PriorityFlagType p);
00094 
00095         static StatusFlagType StatusProto2Rec(uint8_t s);
00096         static uint8_t StatusRec2Proto(StatusFlagType s);
00097 
00098 public:
00099         Task();
00100         ~Task();
00101 
00102         const unsigned char* ParseField(const unsigned char *begin,
00103                 const unsigned char *end, const IConverter *ic = 0);
00104         uint8_t GetRecType() const { return RecType; }
00105         uint32_t GetUniqueId() const { return RecordId; }
00106         void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
00107         void ParseHeader(const Data &data, size_t &offset);
00108         void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
00109         void BuildHeader(Data &data, size_t &offset) const;
00110         void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const;
00111 
00112         void Clear();
00113 
00114         void Dump(std::ostream &os) const;
00115         bool operator<(const Task &other) const { return Summary < other.Summary; }
00116 
00117         // database name
00118         static const char * GetDBName() { return "Tasks"; }
00119         static uint8_t GetDefaultRecType() { return 2; }
00120 
00121 };
00122 
00123 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Task &msg) {
00124         msg.Dump(os);
00125         return os;
00126 }
00127 
00128 } // namespace Barry
00129 
00130 #endif
00131 

Generated on 29 Mar 2010 for Barry by  doxygen 1.6.1