00001
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 <QString>
00027
00028 class QDomElement;
00029 class QStringList;
00030
00031 namespace KPlato
00032 {
00033
00034 class Appointment;
00035 class DateTime;
00036 class Duration;
00037 class Node;
00038 class Task;
00039
00052 class Schedule
00053 {
00054 public:
00055
00056 enum Type { Expected = 0,
00057 Optimistic = 1,
00058 Pessimistic = 2
00059 };
00060
00061 Schedule();
00062 Schedule( Schedule *parent );
00063 Schedule( QString name, Type type, long id );
00064 virtual ~Schedule();
00065
00066 QString name() const { return m_name; }
00067 void setName( QString name ) { m_name = name; }
00068 Type type() const { return m_type; }
00069 void setType( Type type ) { m_type = type; }
00070 void setType( QString type );
00071 QString typeToString( bool translate = false ) const;
00072 long id() const { return m_id; }
00073 void setId( long id ) { m_id = id; }
00074 void setParent( Schedule *parent );
00075 Schedule *parent() const { return m_parent; }
00076 virtual bool isDeleted() const;
00077 virtual void setDeleted( bool on );
00078
00079 virtual Resource *resource() const { return 0; }
00080 virtual Node *node() const { return 0; }
00081
00082 virtual bool loadXML( const QDomElement &element );
00083 virtual void saveXML( QDomElement &element ) const;
00084 void saveCommonXML( QDomElement &element ) const;
00085 void saveAppointments( QDomElement &element ) const;
00086
00088 QList<Appointment*> &appointments() { return m_appointments; }
00090 virtual bool add( Appointment *appointment );
00092 virtual void addAppointment( Schedule * , DateTime & , DateTime & , double = 100 ) {}
00094 void removeAppointment( Appointment *appointment );
00096 virtual void takeAppointment( Appointment *appointment );
00097 Appointment *findAppointment( Schedule *resource, Schedule *node );
00098
00099 Appointment appointmentIntervals() const;
00100
00101 virtual bool isOverbooked() const { return false; }
00102 virtual bool isOverbooked( const DateTime & , const DateTime & ) const { return false; }
00103 virtual QStringList overbookedResources() const;
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 QList<Appointment*> m_appointments;
00170 Schedule *m_parent;
00171
00172 friend class Node;
00173 friend class Task;
00174 friend class Project;
00175 friend class Resource;
00176 friend class RecalculateProjectCmd;
00182 DateTime earliestStart;
00188 DateTime latestFinish;
00193 DateTime startTime;
00199 DateTime endTime;
00204 Duration duration;
00205
00207 bool resourceError;
00209 bool resourceOverbooked;
00211 bool resourceNotAvailable;
00213 bool schedulingError;
00215 bool notScheduled;
00216
00217 DateTime workStartTime;
00218 DateTime workEndTime;
00219 bool inCriticalPath;
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 virtual ~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 virtual void takeAppointment( Appointment *appointment );
00249
00250 virtual Node *node() const { return m_node; }
00251 virtual void setNode( Node *n ) { m_node = n; }
00252
00253 protected:
00254 void init();
00255
00256 private:
00257 Node *m_node;
00258
00259 #ifndef NDEBUG
00260 public:
00261 virtual void printDebug( QString ident );
00262 #endif
00263 };
00264
00269 class ResourceSchedule : public Schedule
00270 {
00271 public:
00272 ResourceSchedule();
00273 ResourceSchedule( Resource *Resource, QString name, Schedule::Type type, long id );
00274 ResourceSchedule( Schedule *parent, Resource *Resource );
00275 virtual ~ResourceSchedule();
00276
00277 virtual bool isDeleted() const
00278 { return m_parent == 0 ? true : m_parent->isDeleted(); }
00279 virtual void addAppointment( Schedule *node, DateTime &start, DateTime &end, double load = 100 );
00280 virtual void takeAppointment( Appointment *appointment );
00281
00282 virtual bool isOverbooked() const;
00283 virtual bool isOverbooked( const DateTime &start, const DateTime &end ) const;
00284 Appointment appointmentIntervals() const;
00285
00286 virtual Resource *resource() const { return m_resource; }
00287 virtual double normalRatePrHour() const;
00288
00289 private:
00290 Resource *m_resource;
00291 Schedule *m_parent;
00292
00293 #ifndef NDEBUG
00294 public:
00295 virtual void printDebug( QString ident );
00296 #endif
00297 };
00298
00303 class MainSchedule : public NodeSchedule
00304 {
00305 public:
00306 MainSchedule();
00307 MainSchedule( Node *node, QString name, Schedule::Type type, long id );
00308 ~MainSchedule();
00309 virtual bool isDeleted() const { return m_deleted; }
00310
00311 virtual bool loadXML( const QDomElement &element, Project &project );
00312 virtual void saveXML( QDomElement &element ) const;
00313
00314 private:
00315
00316 #ifndef NDEBUG
00317 public:
00318 virtual void printDebug( QString ident );
00319 #endif
00320 };
00321
00322
00323 }
00324
00325 #endif