kplato
kptschedule.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KPTSCHEDULE_H
00021 #define KPTSCHEDULE_H
00022
00023 #include "kpteffortcostmap.h"
00024 #include "kptresource.h"
00025
00026 #include <qintdict.h>
00027 #include <qptrlist.h>
00028 #include <qstring.h>
00029
00030 class QDomElement;
00031
00032 namespace KPlato
00033 {
00034
00035 class Appointment;
00036 class DateTime;
00037 class Duration;
00038 class Node;
00039 class Task;
00040
00053 class Schedule
00054 {
00055 public:
00056
00057 enum Type { Expected=0,
00058 Optimistic=1,
00059 Pessimistic=2
00060 };
00061
00062 Schedule();
00063 Schedule(Schedule *parent);
00064 Schedule(QString name, Type type, long id);
00065 ~Schedule();
00066
00067 QString name() const { return m_name; }
00068 void setName(QString name) { m_name = name; }
00069 Type type() const { return m_type; }
00070 void setType(Type type) { m_type = type; }
00071 void setType(QString type);
00072 QString typeToString(bool translate=false) const;
00073 long id() const { return m_id; }
00074 void setId(long id) { m_id = id; }
00075 void setParent(Schedule *parent);
00076 Schedule *parent() const { return m_parent; }
00077 virtual bool isDeleted() const;
00078 virtual void setDeleted(bool on);
00079
00080 virtual Resource *resource() const { return 0; }
00081 virtual Node *node() const { return 0; }
00082
00083 virtual bool loadXML(const QDomElement &element);
00084 virtual void saveXML(QDomElement &element) const;
00085 void saveCommonXML(QDomElement &element) const;
00086 void saveAppointments(QDomElement &element) const;
00087
00089 QPtrList<Appointment> &appointments() { return m_appointments; }
00091 virtual bool add(Appointment *appointment);
00093 virtual void addAppointment(Schedule *, DateTime &, DateTime &, double =100) {}
00095 void removeAppointment(Appointment *appointment);
00097 void takeAppointment(Appointment *appointment);
00098 Appointment *findAppointment(Schedule *resource, Schedule *node);
00099
00100 Appointment appointmentIntervals() const;
00101
00102 virtual bool isOverbooked() const { return false; }
00103 virtual bool isOverbooked(const DateTime &, const DateTime &) const { return false; }
00104
00105 virtual EffortCostMap plannedEffortCostPrDay(const QDate &start, const QDate &end) const;
00106
00108 virtual Duration plannedEffort() const;
00110 virtual Duration plannedEffort(const QDate &date) const;
00112 virtual Duration plannedEffortTo(const QDate &date) const;
00113
00115 virtual Duration actualEffort() const;
00117 virtual Duration actualEffort(const QDate &date) const;
00119 virtual Duration actualEffortTo(const QDate &date) const;
00120
00125 virtual double plannedCost() const;
00126
00128 virtual double plannedCost(const QDate &date) const;
00133 virtual double plannedCostTo(const QDate &date) const;
00138 virtual double actualCost() const;
00140 virtual double actualCost(const QDate &date) const;
00142 virtual double actualCostTo(const QDate &date) const;
00143
00145 double effortPerformanceIndex(const QDate &, bool *) { return 0.0; }
00147 double costPerformanceIndex(const QDate &, bool *) { return 0.0; }
00148
00149 virtual double normalRatePrHour() const { return 0.0; }
00150
00151 void setEarliestStart(DateTime &dt) { earliestStart = dt; }
00152 void setLatestFinish(DateTime &dt) { latestFinish = dt; }
00153
00154 virtual void initiateCalculation();
00155 virtual void calcResourceOverbooked();
00156
00157 void setScheduled(bool on) { notScheduled = !on; }
00158 bool isScheduled() const { return !notScheduled; }
00159
00160 DateTime start() const { return startTime; }
00161 DateTime end() const { return endTime; }
00162
00163 protected:
00164 QString m_name;
00165 Type m_type;
00166 long m_id;
00167 bool m_deleted;
00168
00169 QPtrList<Appointment> m_appointments;
00170 Schedule *m_parent;
00171
00172 friend class Node;
00173 friend class Task;
00174 friend class Project;
00175 friend class Resource;
00181 DateTime earliestStart;
00187 DateTime latestFinish;
00192 DateTime startTime;
00198 DateTime endTime;
00203 Duration duration;
00204
00206 bool resourceError;
00208 bool resourceOverbooked;
00210 bool resourceNotAvailable;
00212 bool schedulingError;
00214 bool notScheduled;
00215
00216 DateTime workStartTime;
00217 DateTime workEndTime;
00218 bool inCriticalPath;
00219
00220
00221 #ifndef NDEBUG
00222 public:
00223 virtual void printDebug(QString ident);
00224 #endif
00225 };
00226
00231 class NodeSchedule : public Schedule
00232 {
00233 public:
00234 NodeSchedule();
00235 NodeSchedule(Node *node, QString name, Schedule::Type type, long id);
00236 NodeSchedule(Schedule *parent, Node *node);
00237 ~NodeSchedule();
00238
00239 virtual bool isDeleted() const
00240 { return m_parent == 0 ? true : m_parent->isDeleted(); }
00241 void setDeleted(bool on);
00242
00243 virtual bool loadXML(const QDomElement &element);
00244 virtual void saveXML(QDomElement &element) const;
00245
00246
00247 virtual void addAppointment(Schedule *resource, DateTime &start, DateTime &end, double load=100);
00248
00249 virtual Node *node() const { return m_node; }
00250 virtual void setNode(Node *n) { m_node = n; }
00251
00252 protected:
00253 void init();
00254
00255 private:
00256 Node *m_node;
00257
00258 #ifndef NDEBUG
00259 public:
00260 virtual void printDebug(QString ident);
00261 #endif
00262 };
00263
00268 class ResourceSchedule : public Schedule
00269 {
00270 public:
00271 ResourceSchedule();
00272 ResourceSchedule(Resource *Resource, QString name, Schedule::Type type, long id);
00273 ResourceSchedule(Schedule *parent, Resource *Resource);
00274 ~ResourceSchedule();
00275
00276 virtual bool isDeleted() const
00277 { return m_parent == 0 ? true : m_parent->isDeleted(); }
00278 virtual void addAppointment(Schedule *node, DateTime &start, DateTime &end, double load=100);
00279
00280 virtual bool isOverbooked() const;
00281 virtual bool isOverbooked(const DateTime &start, const DateTime &end) const;
00282 Appointment appointmentIntervals() const;
00283
00284 virtual Resource *resource() const { return m_resource; }
00285 virtual double normalRatePrHour() const;
00286
00287 private:
00288 Resource *m_resource;
00289 Schedule *m_parent;
00290
00291 #ifndef NDEBUG
00292 public:
00293 virtual void printDebug(QString ident);
00294 #endif
00295 };
00296
00301 class MainSchedule : public NodeSchedule
00302 {
00303 public:
00304 MainSchedule();
00305 MainSchedule(Node *node, QString name, Schedule::Type type, long id);
00306 ~MainSchedule();
00307 virtual bool isDeleted() const { return m_deleted; }
00308
00309 virtual bool loadXML(const QDomElement &element, Project &project);
00310 virtual void saveXML(QDomElement &element) const;
00311
00312 private:
00313
00314 #ifndef NDEBUG
00315 public:
00316 virtual void printDebug(QString ident);
00317 #endif
00318 };
00319
00320
00321 }
00322
00323 #endif
|