kplato

kpttask.h
1/* This file is part of the KDE project
2 Copyright (C) 2001 Thomas Zander zander@kde.org
3 Copyright (C) 2004 Dag Andersen <danders@get2net.dk>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KPTTASK_H
22#define KPTTASK_H
23
24#include "kptnode.h"
25#include "kptduration.h"
26#include "kptresource.h"
27
28#include <tqptrlist.h>
29
30namespace KPlato
31{
32
33class DateTime;
34
40class Task : public Node {
41public:
42 Task(Node *parent = 0);
43 Task(Task &task, Node *parent = 0);
44 ~Task();
45
47 virtual int type() const;
48
54
61
66 ResourceGroupRequest *resourceGroupRequest(ResourceGroup *group) const;
67 void clearResourceRequests();
68 void addRequest(ResourceGroup *group, int numResources);
69 void addRequest(ResourceGroupRequest *request);
70 void takeRequest(ResourceGroupRequest *request);
71 int units() const;
72 int workUnits() const;
73 void makeAppointments();
79
80 void setConstraint(Node::ConstraintType type);
81
83 virtual bool load(TQDomElement &element, Project &project);
85 virtual void save(TQDomElement &element) const;
87 virtual void saveAppointments(TQDomElement &element, long id) const;
92 virtual EffortCostMap plannedEffortCostPrDay(const TQDate &start, const TQDate &end) const;
93
95 virtual Duration plannedEffort();
97 virtual Duration plannedEffort(const TQDate &date);
99 virtual Duration plannedEffortTo(const TQDate &date);
100
102 virtual Duration actualEffort();
104 virtual Duration actualEffort(const TQDate &date);
106 virtual Duration actualEffortTo(const TQDate &date);
107
111 virtual double plannedCost();
113 virtual double plannedCost(const TQDate &/*date*/);
115 virtual double plannedCostTo(const TQDate &/*date*/);
116
120 virtual double actualCost();
122 virtual double actualCost(const TQDate &/*date*/);
124 virtual double actualCostTo(const TQDate &/*date*/);
125
127 double effortPerformanceIndex(const TQDate &date, bool *error=0);
129 double costPerformanceIndex(const TQDate &date, bool *error=0);
130
131 void initiateCalculation(Schedule &sch);
137 void initiateCalculationLists(TQPtrList<Node> &startnodes, TQPtrList<Node> &endnodes, TQPtrList<Node> &summarytasks);
145 DateTime calculateForward(int use);
163 DateTime scheduleForward(const DateTime &earliest, int use);
173 DateTime scheduleBackward(const DateTime &latest, int use);
174
179 void adjustSummarytask();
180
184 Duration calcDuration(const DateTime &time, const Duration &effort, bool backward);
185
186 // Proxy relations are relations to/from summarytasks.
187 // These relations are distrubuted to the relevant tasks before calculation.
188 void clearProxyRelations();
189 void addParentProxyRelations(TQPtrList<Relation> &list);
190 void addChildProxyRelations(TQPtrList<Relation> &list);
191 void addParentProxyRelation(Node *node, const Relation *rel);
192 void addChildProxyRelation(Node *node, const Relation *rel);
193
195 bool isEndNode() const;
197 bool isStartNode() const;
198
205 virtual DateTime workStartTime() const;
206
213 virtual DateTime workEndTime() const;
214
241
243 virtual bool isCritical();
245 virtual bool calcCriticalPath(bool fromEnd);
246
248 virtual void setCurrentSchedule(long id);
249
250 virtual bool effortMetError() const;
251
252 struct Progress {
253 Progress() { started = finished = false; percentFinished = 0; }
254 bool operator==(struct Progress &p) {
255 return started == p.started && finished == p.finished &&
256 startTime == p.startTime && finishTime == p.finishTime &&
257 percentFinished == p.percentFinished &&
258 remainingEffort == p.remainingEffort &&
259 totalPerformed == p.totalPerformed;
260 }
261 bool operator!=(struct Progress &p) { return !(*this == p); }
262 struct Progress &operator=(struct Progress &p) {
263 started = p.started; finished = p.finished;
264 startTime = p.startTime; finishTime = p.finishTime;
265 percentFinished = p.percentFinished;
266 remainingEffort = p.remainingEffort;
267 totalPerformed = p.totalPerformed;
268 return *this;
269 }
270 bool started, finished;
271 DateTime startTime, finishTime;
272 int percentFinished;
273 Duration remainingEffort;
274 Duration totalPerformed;
275 };
276 struct Progress &progress() { return m_progress; }
277
278private:
279 DateTime calculateSuccessors(const TQPtrList<Relation> &list, int use);
280 DateTime calculatePredeccessors(const TQPtrList<Relation> &list, int use);
281 DateTime scheduleSuccessors(const TQPtrList<Relation> &list, int use);
282 DateTime schedulePredeccessors(const TQPtrList<Relation> &list, int use);
283
284 DateTime workStartAfter(const DateTime &dt);
285 DateTime workFinishBefore(const DateTime &dt);
286
287private:
288 TQPtrList<ResourceGroup> m_resource;
289
290 ResourceRequestCollection *m_requests;
291
292 TQPtrList<Relation> m_parentProxyRelations;
293 TQPtrList<Relation> m_childProxyRelations;
294
295 struct Progress m_progress;
296
297#ifndef NDEBUG
298public:
299 void printDebug(bool children, TQCString indent);
300#endif
301
302};
303
304} //KPlato namespace
305
306#endif
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 DateTime startTime() const
Return the scheduled start time.
Definition kptnode.h:174
Project is the main node in a project, it contains child nodes and possibly sub-projects.
Definition kptproject.h:52
The relation class couples a 2 nodes together which are dependent on each other.
Definition kptrelation.h:45
This class represents a group of similar resources to be assigned to a task e.g.
Definition kptresource.h:66
The Schedule class holds data calculated during project calculation and scheduling,...
Definition kptschedule.h:55
virtual Duration plannedEffortTo(const TQDate &date)
Returns the planned effort up to and including date.
Definition kpttask.cpp:381
virtual double plannedCost()
Returns the total planned cost for this task (or subtasks).
Definition kpttask.cpp:444
bool isStartNode() const
Check if this node has any dependent parent nodes.
Definition kpttask.cpp:1380
virtual EffortCostMap plannedEffortCostPrDay(const TQDate &start, const TQDate &end) const
Returns a list of planned effort and cost for this task for the interval start, end inclusive.
Definition kpttask.cpp:342
Duration freeFloat()
Return the duration by which an activity can be delayed or extended without affecting the start of an...
Definition kpttask.h:230
DateTime scheduleForward(const DateTime &earliest, int use)
Schedules the task within the limits of earliestStart and latestFinish.
Definition kpttask.cpp:879
Duration * getExpectedDuration()
Returns the (previously) calculated duration.
Definition kpttask.cpp:88
virtual bool calcCriticalPath(bool fromEnd)
Calculate critical path.
Definition kpttask.cpp:1464
virtual int type() const
Return task type. Can be Type_Task, Type_Summarytask ot Type_Milestone.
Definition kpttask.cpp:74
virtual void save(TQDomElement &element) const
Save to document.
Definition kpttask.cpp:281
virtual bool isCritical()
A task is critical if there is no positive float.
Definition kpttask.cpp:1456
Duration startFloat()
Return the duration from Early Start to Late Start.
Definition kpttask.h:234
Duration finishFloat()
Return the duration the task has at its finish before a successor task starts.
Definition kpttask.h:240
bool isEndNode() const
Check if this node has any dependent child nodes.
Definition kpttask.cpp:1367
virtual Duration plannedEffort()
Returns the total planned effort for this task (or subtasks).
Definition kpttask.cpp:351
DateTime calculateBackward(int use)
Calculates ref m_durationBackward from ref latestFinish and returns the resulting start time,...
Definition kpttask.cpp:752
virtual double plannedCostTo(const TQDate &)
Planned cost up to and including date.
Definition kpttask.cpp:472
virtual void saveAppointments(TQDomElement &element, long id) const
Save appointments for schedule with id.
Definition kpttask.cpp:330
virtual Duration actualEffortTo(const TQDate &date)
Returns the actual effort up to and including date.
Definition kpttask.cpp:430
virtual void setCurrentSchedule(long id)
Set current schedule to schedule with identity id, for me nd my children.
Definition kpttask.cpp:1515
Duration positiveFloat()
Return the duration that an activity's start can be delayed without affecting the project completion ...
Definition kpttask.cpp:1425
void calcResourceOverbooked()
Calculates if the assigned resource is overbooked within the duration of this task.
Definition kpttask.cpp:161
virtual double actualCost()
Returns the actaually reported cost for this task (or subtasks).
Definition kpttask.cpp:486
Duration * getRandomDuration()
Instead of using the expected duration, generate a random value using the Distribution of each Task.
Definition kpttask.cpp:94
virtual DateTime workStartTime() const
Return the time when work can actually start on this task.
Definition kpttask.cpp:1396
ResourceGroupRequest * resourceGroupRequest(ResourceGroup *group) const
Return the resource request made to group (There should be only one).
Definition kpttask.cpp:98
Duration negativeFloat()
Return the duration by which the duration of an activity or path has to be reduced in order to fullfi...
Definition kpttask.h:225
virtual double actualCostTo(const TQDate &)
Actual cost up to and including date.
Definition kpttask.cpp:514
virtual bool load(TQDomElement &element, Project &project)
Load from document.
Definition kpttask.cpp:172
DateTime calculateForward(int use)
Calculates ref m_durationForward from ref earliestStart and returns the resulting end time,...
Definition kpttask.cpp:625
virtual Duration actualEffort()
Returns the total actual effort for this task (or subtasks).
Definition kpttask.cpp:396
void initiateCalculationLists(TQPtrList< Node > &startnodes, TQPtrList< Node > &endnodes, TQPtrList< Node > &summarytasks)
Sets up the lists used for calculation.
Definition kpttask.cpp:569
double costPerformanceIndex(const TQDate &date, bool *error=0)
Cost performance index.
Definition kpttask.cpp:544
double effortPerformanceIndex(const TQDate &date, bool *error=0)
Effort based performance index.
Definition kpttask.cpp:529
Duration calcDuration(const DateTime &time, const Duration &effort, bool backward)
Return the duration calculated on bases of the requested resources.
Definition kpttask.cpp:1262
virtual DateTime workEndTime() const
Return the time when work can actually finish on this task.
Definition kpttask.cpp:1404
void adjustSummarytask()
Summarytasks (with milestones) need special treatment because milestones are always 'glued' to their ...
Definition kpttask.cpp:1240
DateTime scheduleBackward(const DateTime &latest, int use)
Schedules the task within the limits of earliestStart and latestFinish.
Definition kpttask.cpp:1074