kplato

kptschedule.h
1/* This file is part of the KDE project
2 Copyright (C) 2005 Dag Andersen <danders@get2net.dk>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation;
7 version 2 of the License.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef KPTSCHEDULE_H
21#define KPTSCHEDULE_H
22
23#include "kpteffortcostmap.h"
24#include "kptresource.h"
25
26#include <tqintdict.h>
27#include <tqptrlist.h>
28#include <tqstring.h>
29
30class TQDomElement;
31class TQStringList;
32
33namespace KPlato
34{
35
36class Appointment;
37class DateTime;
38class Duration;
39class Node;
40class Task;
41
54class Schedule
55{
56public:
57 //NOTE: Must match Effort::Use atm.
58 enum Type { Expected=0, //Effort::Use_Expected
59 Optimistic=1, //Effort::Use_Optimistic
60 Pessimistic=2 //Effort::Use_Pessimistic
61 };
62
63 Schedule();
64 Schedule(Schedule *parent);
65 Schedule(TQString name, Type type, long id);
66 ~Schedule();
67
68 TQString name() const { return m_name; }
69 void setName(TQString name) { m_name = name; }
70 Type type() const { return m_type; }
71 void setType(Type type) { m_type = type; }
72 void setType(TQString type);
73 TQString typeToString(bool translate=false) const;
74 long id() const { return m_id; }
75 void setId(long id) { m_id = id; }
76 void setParent(Schedule *parent);
77 Schedule *parent() const { return m_parent; }
78 virtual bool isDeleted() const;
79 virtual void setDeleted(bool on);
80
81 virtual Resource *resource() const { return 0; }
82 virtual Node *node() const { return 0; }
83
84 virtual bool loadXML(const TQDomElement &element);
85 virtual void saveXML(TQDomElement &element) const;
86 void saveCommonXML(TQDomElement &element) const;
87 void saveAppointments(TQDomElement &element) const;
88
90 TQPtrList<Appointment> &appointments() { return m_appointments; }
92 virtual bool add(Appointment *appointment);
94 virtual void addAppointment(Schedule */*other*/, DateTime &/*start*/, DateTime &/*end*/, double /*load*/=100) {}
96 void removeAppointment(Appointment *appointment);
98 void takeAppointment(Appointment *appointment);
99 Appointment *findAppointment(Schedule *resource, Schedule *node);
100
101 Appointment appointmentIntervals() const;
102
103 virtual bool isOverbooked() const { return false; }
104 virtual bool isOverbooked(const DateTime &/*start*/, const DateTime &/*end*/) const { return false; }
105 virtual TQStringList overbookedResources() const;
106
107 virtual EffortCostMap plannedEffortCostPrDay(const TQDate &start, const TQDate &end) const;
108
110 virtual Duration plannedEffort() const;
112 virtual Duration plannedEffort(const TQDate &date) const;
114 virtual Duration plannedEffortTo(const TQDate &date) const;
115
117 virtual Duration actualEffort() const;
119 virtual Duration actualEffort(const TQDate &date) const;
121 virtual Duration actualEffortTo(const TQDate &date) const;
122
127 virtual double plannedCost() const;
128
130 virtual double plannedCost(const TQDate &date) const;
135 virtual double plannedCostTo(const TQDate &date) const;
140 virtual double actualCost() const;
142 virtual double actualCost(const TQDate &date) const;
144 virtual double actualCostTo(const TQDate &date) const;
145
147 double effortPerformanceIndex(const TQDate &/*date*/, bool */*error=0*/) { return 0.0; }
149 double costPerformanceIndex(const TQDate &/*date*/, bool */*error=0*/) { return 0.0; }
150
151 virtual double normalRatePrHour() const { return 0.0; }
152
153 void setEarliestStart(DateTime &dt) { earliestStart = dt; }
154 void setLatestFinish(DateTime &dt) { latestFinish = dt; }
155
156 virtual void initiateCalculation();
157 virtual void calcResourceOverbooked();
158
159 void setScheduled(bool on) { notScheduled = !on; }
160 bool isScheduled() const { return !notScheduled; }
161
162 DateTime start() const { return startTime; }
163 DateTime end() const { return endTime; }
164
165protected:
166 TQString m_name;
167 Type m_type;
168 long m_id;
169 bool m_deleted;
170
171 TQPtrList<Appointment> m_appointments;
172 Schedule *m_parent;
173
174 friend class Node;
175 friend class Task;
176 friend class Project;
177 friend class Resource;
178 friend class RecalculateProjectCmd;
207
218
219 DateTime workStartTime;
220 DateTime workEndTime;
221 bool inCriticalPath;
222
223#ifndef NDEBUG
224public:
225 virtual void printDebug(TQString ident);
226#endif
227};
228
233class NodeSchedule : public Schedule
234{
235public:
236 NodeSchedule();
237 NodeSchedule(Node *node, TQString name, Schedule::Type type, long id);
238 NodeSchedule(Schedule *parent, Node *node);
239 ~NodeSchedule();
240
241 virtual bool isDeleted() const
242 { return m_parent == 0 ? true : m_parent->isDeleted(); }
243 void setDeleted(bool on);
244
245 virtual bool loadXML(const TQDomElement &element);
246 virtual void saveXML(TQDomElement &element) const;
247
248// tasks------------>
249 virtual void addAppointment(Schedule *resource, DateTime &start, DateTime &end, double load=100);
250
251 virtual Node *node() const { return m_node; }
252 virtual void setNode(Node *n) { m_node = n; }
253
254protected:
255 void init();
256
257private:
258 Node *m_node;
259
260#ifndef NDEBUG
261public:
262 virtual void printDebug(TQString ident);
263#endif
264};
265
270class ResourceSchedule : public Schedule
271{
272public:
273 ResourceSchedule();
274 ResourceSchedule(Resource *Resource, TQString name, Schedule::Type type, long id);
275 ResourceSchedule(Schedule *parent, Resource *Resource);
276 ~ResourceSchedule();
277
278 virtual bool isDeleted() const
279 { return m_parent == 0 ? true : m_parent->isDeleted(); }
280 virtual void addAppointment(Schedule *node, DateTime &start, DateTime &end, double load=100);
281
282 virtual bool isOverbooked() const;
283 virtual bool isOverbooked(const DateTime &start, const DateTime &end) const;
284 Appointment appointmentIntervals() const;
285
286 virtual Resource *resource() const { return m_resource; }
287 virtual double normalRatePrHour() const;
288
289private:
290 Resource *m_resource;
291 Schedule *m_parent;
292
293#ifndef NDEBUG
294public:
295 virtual void printDebug(TQString ident);
296#endif
297};
298
303class MainSchedule : public NodeSchedule
304{
305public:
306 MainSchedule();
307 MainSchedule(Node *node, TQString name, Schedule::Type type, long id);
308 ~MainSchedule();
309 virtual bool isDeleted() const { return m_deleted; }
310
311 virtual bool loadXML(const TQDomElement &element, Project &project);
312 virtual void saveXML(TQDomElement &element) const;
313
314private:
315
316#ifndef NDEBUG
317public:
318 virtual void printDebug(TQString ident);
319#endif
320};
321
322
323} //namespace KPlato
324
325#endif
A resource (Resource) can be scheduled to be used at any time, this is represented internally with Ap...
DateTime is a TQDateTime which knows about Duration.
Definition kptdatetime.h:33
The duration class can be used to store a timespan in a convenient format.
Definition kptduration.h:34
virtual void addAppointment(Schedule *resource, DateTime &start, DateTime &end, double load=100)
Adds appointment to both this resource schedule and node schedule.
This class represents any node in the project, a node can be a project or a subproject or any task.
Definition kptnode.h:57
Project is the main node in a project, it contains child nodes and possibly sub-projects.
Definition kptproject.h:52
virtual void addAppointment(Schedule *node, DateTime &start, DateTime &end, double load=100)
Adds appointment to both this resource schedule and node schedule.
The Schedule class holds data calculated during project calculation and scheduling,...
Definition kptschedule.h:55
virtual Duration plannedEffort() const
Returns the total planned effort for this task (or subtasks).
DateTime startTime
startTime is the scheduled start time.
virtual double plannedCostTo(const TQDate &date) const
Planned cost from start of activity up to and including date is the sum of all resource costs and oth...
bool resourceNotAvailable
Set if the requested resource is not available.
bool resourceOverbooked
Set if the assigned resource is overbooked.
double effortPerformanceIndex(const TQDate &, bool *)
Effort based performance index.
void removeAppointment(Appointment *appointment)
removes appointment and deletes it (independent of setAutoDelete)
virtual double actualCostTo(const TQDate &date) const
Actual cost up to and including date.
virtual bool add(Appointment *appointment)
Adds appointment to this schedule only.
bool resourceError
Set if EffortType == Effort, but no resource is requested.
virtual Duration actualEffort() const
Returns the total actual effort for this task (or subtasks).
Duration duration
duration is the scheduled duration which depends on e.g.
DateTime latestFinish
latestFinish is calculated by PERT/CPM.
double costPerformanceIndex(const TQDate &, bool *)
Cost performance index.
virtual void addAppointment(Schedule *, DateTime &, DateTime &, double=100)
Adds appointment to both this resource schedule and node schedule.
Definition kptschedule.h:94
void takeAppointment(Appointment *appointment)
removes appointment without deleting it (independent of setAutoDelete)
virtual double actualCost() const
Actual cost is the sum total of the reported costs actually used for this node.
virtual double plannedCost() const
Planned cost is the sum total of all resources and other costs planned for this node.
bool notScheduled
Set if the node has not been scheduled.
DateTime endTime
m_endTime is the scheduled finish time.
virtual Duration actualEffortTo(const TQDate &date) const
Returns the total actual effort for this task (or subtasks) up to and including date.
TQPtrList< Appointment > & appointments()
Return the list of appointments.
Definition kptschedule.h:90
DateTime earliestStart
earliestStart is calculated by PERT/CPM.
bool schedulingError
Set if the task cannot be scheduled to fullfill all the constraints.
virtual Duration plannedEffortTo(const TQDate &date) const
Returns the planned effort up to and including date.
A task in the scheduling software is represented by this class.
Definition kpttask.h:40