00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef TASK_H
00021 #define TASK_H
00022
00023 #include <cstdio>
00024 #include <string>
00025 #include <vector>
00026 #include <cstdarg>
00027 using namespace std;
00028
00029 #include "base.h"
00030
00031 #include "namedid.h"
00032 #include "timeblock.h"
00033 #include "note.h"
00034 #include "resource.h"
00035 #include "item.h"
00036
00037 class TASK : public NAMED_ID
00038 {
00039 public:
00040
00041 typedef vector<TASK *> PTRLIST;
00042
00043 TASK(char *id, char *name, int duration);
00044 virtual ~TASK(){}
00045
00046 const char * desc() const { return mDesc; };
00047 const char * overrun() const { return mOverrun; };
00048 void setOverrun( char * overrun ) { mOverrun = strdup(overrun); };
00049 void AddNote(const string & note);
00050 NOTE_ITERATOR begin_notes() { return mNotes.begin(); };
00051 NOTE_ITERATOR end_notes() { return mNotes.end(); };
00052
00053 void setDaysDone(int days);
00054 int nDays() { return mnDays; };
00055 void Blockify();
00056 int block() { return mBlock; };
00057 void setDesc( char * desc );
00058 void setPercentComplete( double c );
00059 double percent_complete() const { return mPercentComplete; };
00060 void setStart( int day ) { mStart = day; };
00061 int start() const { return mStart; };
00062 void setFinish( int day ) { mFinish = day; };
00063 int finish() { return mFinish; };
00064 void setDuration( int d ) { mDuration = d; };
00065 int duration() { return mDuration; };
00066 void setAssigned( RESOURCE *res ) { mAssigned = res; };
00067 RESOURCE *assigned() const { return mAssigned; };
00068
00070
00071
00072
00073 int fullduration() const { return mFullduration; };
00074 void setFullduration( int fd ) { mFullduration = fd; };
00075 int origfullduration() const { return mOrigfullduration; };
00076
00077
00078 void setOrigfullduration() { mOrigfullduration = mFullduration; };
00079 int bstart() const { return mBstart; };
00080 void setBstart( int day ) { mBstart = day; };
00081 int bfinish() const { return mBfinish; };
00082 void setBfinish( int day ) { mBfinish = day; };
00083 int astart() const { return mAstart; };
00084 void setAstart( int day ) { mAstart = day; };
00085 int afinish() const { return mAfinish; };
00086 void setAfinish( int day ) { mAfinish = day; };
00087 void setLstart( int day ) { mLstart = day; };
00088 int lstart() { return mLstart; };
00089 void setLfinish( int day ) { mLfinish = day; };
00090 int lfinish() { return mLfinish; };
00091 int slack() { return mSlack; };
00092 void setSlack( int s ) { mSlack = s; };
00093
00094 int children() { return mChildren; };
00095 int parents() { return mParents; };
00096 void addDepends( TASK * depends );
00097 PTRLIST::const_iterator begin_depends() { return mDepends.begin(); };
00098 PTRLIST::const_iterator end_depends() { return mDepends.end(); };
00099 void addFollows( TASK * follows );
00100 PTRLIST::const_iterator begin_follows() { return mFollows.begin(); };
00101 PTRLIST::const_iterator end_follows() { return mFollows.end(); };
00102
00103 virtual bool isVacation() const { return false; }
00104
00105 void addTimeBlock(RESOURCE *r, int start, int finish, TimeBlock::Type type);
00106 TaskTimeBlockIterator begin_when() { return mWhen.begin(); };
00107 TaskTimeBlockIterator end_when() { return mWhen.end(); };
00108 void addReverseTimeBlock(RESOURCE *r, int start, int finish, TimeBlock::Type type);
00109 TaskTimeBlockIterator begin_rwhen() { return mRwhen.begin(); };
00110 TaskTimeBlockIterator end_rwhen() { return mRwhen.end(); };
00111 void copyWhenToReverseWhen();
00112 bool DayBooked( int dayNo );
00113
00114 bool overlap(int start, int finish);
00115 bool isActiveDuring(int start, int finish);
00116
00117 void addCandidate(RESOURCE *res);
00118 RESOURCE::PTRLIST::const_iterator begin_cando() { return mCando.begin(); };
00119 RESOURCE::PTRLIST::const_iterator end_cando() { return mCando.end(); };
00120 int numCandidates() { return mCando.size(); };
00121
00122 void addItem(ITEM * item) { mItems.push_back(item); };
00123
00124 double timeCost();
00125 double itemCost();
00126 int numItems() { return mItems.size(); };
00127 ITEM::PTRLIST::const_iterator begin_items() { return mItems.begin(); };
00128 ITEM::PTRLIST::const_iterator end_items() { return mItems.end(); };
00129
00130
00131
00132
00133 int scheduled;
00134 int remaining;
00135 int rscheduled;
00136 int rremaining;
00137
00138
00139
00140
00141 int x1,y1,x2,y2;
00142 int nx, ny;
00143
00144 private:
00145
00146 char *mDesc;
00147 char *mOverrun;
00148 int mDuration;
00149 int mFullduration;
00150
00151 int mOrigfullduration;
00152 int mStart;
00153 int mFinish;
00154 int mLstart;
00155 int mLfinish;
00156 int mSlack;
00157 int mAstart;
00158 int mAfinish;
00159 int mBstart;
00160 int mBfinish;
00161 bool mBlock;
00162
00163 double mPercentComplete;
00164 RESOURCE *mAssigned;
00165 NOTES mNotes;
00166 int mnDays;
00167
00168 PTRLIST mDepends;
00169 int mChildren;
00170 PTRLIST mFollows;
00171 int mParents;
00172
00173 TaskTimeBlockList mWhen;
00174 TaskTimeBlockList mRwhen;
00175
00176
00177 RESOURCE::PTRLIST mCando;
00178
00179
00181
00182
00183
00184
00185
00186 ITEM::PTRLIST mItems;
00187
00188 void Error(char *fmt, ...);
00189 };
00190
00191
00192 class CompareTaskStarts
00193 {
00194 public:
00195 bool operator()(const TASK * t1, const TASK * t2) const
00196 { return t1->start() < t2->start(); };
00197 };
00198
00199 class CompareTaskResources
00200 {
00201 public:
00202 bool operator()(const TASK * t1, const TASK * t2) const ;
00203 };
00204
00205
00206
00207 #endif