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

Generated on Wed Sep 24 21:27:32 2008 for Barry by  doxygen 1.5.1