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-2009, 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 <vector>
00029 #include <string>
00030 #include <stdint.h>
00031 
00032 namespace Barry {
00033 
00034 // forward declarations
00035 class IConverter;
00036 
00037 class BXEXPORT Task
00038 {
00039 public:
00040         typedef std::vector<UnknownField>                       UnknownsType;
00041         uint8_t RecType;
00042         uint32_t RecordId;
00043 
00044         uint8_t TaskType;
00045         std::string Summary;
00046         std::string Notes;
00047         std::string Categories;
00048         std::string UID;
00049 
00050         time_t StartTime;
00051         time_t DueTime;
00052         time_t AlarmTime;
00053         int TimeZoneCode;
00054 
00055         enum AlarmFlagType
00056         {
00057                 Date = 1,
00058                 Relative
00059         };
00060         AlarmFlagType AlarmType;
00061 
00062         unsigned short Interval;
00063         enum RecurringCodeType {
00064                 Day = 1,                //< eg. every day
00065                                         //< set: nothing
00066                 MonthByDate = 3,        //< eg. every month on the 12th
00067                                         //< set: DayOfMonth
00068                 MonthByDay = 4,         //< eg. every month on 3rd Wed
00069                                         //< set: DayOfWeek and WeekOfMonth
00070                 YearByDate = 5,         //< eg. every year on March 5
00071                                         //< set: DayOfMonth and MonthOfYear
00072                 YearByDay = 6,          //< eg. every year on 3rd Wed of Jan
00073                                         //< set: DayOfWeek, WeekOfMonth, and
00074                                         //<      MonthOfYear
00075                 Week = 12               //< eg. every week on Mon and Fri
00076                                         //< set: WeekDays
00077         };
00078         RecurringCodeType RecurringType;
00079         time_t RecurringEndTime;        
00080         unsigned short                  // recurring details, depending on type
00081                 DayOfWeek,              // 0-6
00082                 WeekOfMonth,            // 1-5
00083                 DayOfMonth,             // 1-31
00084                 MonthOfYear;            // 1-12
00085         unsigned char WeekDays;         // bitmask, bit 0 = sunday
00086 
00087         int ClassType;
00088         enum PriorityFlagType
00089         {
00090                 High = 0,
00091                 Normal,
00092                 Low
00093         };
00094         PriorityFlagType PriorityFlag;
00095 
00096         enum StatusFlagType
00097         {
00098                 NotStarted = 0,
00099                 InProgress,
00100                 Completed,
00101                 Waiting,
00102                 Deferred
00103         };
00104         StatusFlagType StatusFlag;
00105 
00106         bool Recurring;
00107         bool Perpetual;
00108         bool DueDateFlag;       // true if due date is set
00109 
00110         UnknownsType Unknowns;
00111 
00112 public: 
00113         Task();
00114         ~Task();
00115 
00116         const unsigned char* ParseField(const unsigned char *begin,
00117                 const unsigned char *end, const IConverter *ic = 0);
00118         void ParseRecurrenceData(const void *data);
00119         void BuildRecurrenceData(void *data);
00120         uint8_t GetRecType() const { return RecType; }
00121         uint32_t GetUniqueId() const { return RecordId; }
00122         void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
00123         void ParseHeader(const Data &data, size_t &offset);
00124         void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
00125         void BuildHeader(Data &data, size_t &offset) const;
00126 
00127         void Clear();
00128 
00129         void Dump(std::ostream &os) const;
00130         bool operator<(const Task &other) const { return Summary < other.Summary; }
00131 
00132         // database name
00133         static const char * GetDBName() { return "Tasks"; }
00134         static uint8_t GetDefaultRecType() { return 2; }
00135 
00136 };
00137 
00138 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Task &msg) {
00139         msg.Dump(os);
00140         return os;
00141 }
00142 
00143 } // namespace Barry
00144 
00145 #endif
00146 

Generated on Mon Jan 12 10:51:13 2009 for Barry by  doxygen 1.5.7.1