kplato

kpttask.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Thomas Zander zander@kde.org
00003    Copyright (C) 2004 Dag Andersen <danders@get2net.dk>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KPTTASK_H
00022 #define KPTTASK_H
00023 
00024 #include "kptnode.h"
00025 #include "kptduration.h"
00026 #include "kptresource.h"
00027 
00028 #include <qptrlist.h>
00029 
00030 namespace KPlato
00031 {
00032 
00033 class DateTime;
00034 
00040 class Task : public Node {
00041 public:
00042     Task(Node *parent = 0);
00043     Task(Task &task, Node *parent = 0);
00044     ~Task();
00045 
00047     virtual int type() const;
00048 
00053     Duration *getExpectedDuration();
00054 
00060     Duration *getRandomDuration();
00061 
00066     ResourceGroupRequest *resourceGroupRequest(ResourceGroup *group) const;
00067     void clearResourceRequests();
00068     void addRequest(ResourceGroup *group, int numResources);
00069     void addRequest(ResourceGroupRequest *request);
00070     void takeRequest(ResourceGroupRequest *request);
00071     int units() const;
00072     int workUnits() const;
00073     void makeAppointments();
00078     void calcResourceOverbooked();
00079     
00080     void setConstraint(Node::ConstraintType type);
00081 
00083     virtual bool load(QDomElement &element, Project &project);
00085     virtual void save(QDomElement &element) const;
00087     virtual void saveAppointments(QDomElement &element, long id) const;
00092     virtual EffortCostMap plannedEffortCostPrDay(const QDate &start, const QDate &end) const;
00093     
00095     virtual Duration plannedEffort();
00097     virtual Duration plannedEffort(const QDate &date);
00099     virtual Duration plannedEffortTo(const QDate &date);
00100     
00102     virtual Duration actualEffort();
00104     virtual Duration actualEffort(const QDate &date);
00106     virtual Duration actualEffortTo(const QDate &date);
00107     
00111     virtual double plannedCost();
00113     virtual double plannedCost(const QDate &/*date*/);
00115     virtual double plannedCostTo(const QDate &/*date*/);
00116     
00120     virtual double actualCost();
00122     virtual double actualCost(const QDate &/*date*/);
00124     virtual double actualCostTo(const QDate &/*date*/);
00125 
00127     double effortPerformanceIndex(const QDate &date, bool *error=0);
00129     double costPerformanceIndex(const QDate &date, bool *error=0);
00130     
00131     void initiateCalculation(Schedule &sch);
00137     void initiateCalculationLists(QPtrList<Node> &startnodes, QPtrList<Node> &endnodes, QPtrList<Node> &summarytasks);
00145     DateTime calculateForward(int use);
00153     DateTime calculateBackward(int use);
00163     DateTime scheduleForward(const DateTime &earliest, int use);
00173     DateTime scheduleBackward(const DateTime &latest, int use);
00174     
00179     void adjustSummarytask();
00180     
00184     Duration calcDuration(const DateTime &time, const Duration &effort, bool backward);
00185 
00186     // Proxy relations are relations to/from summarytasks. 
00187     // These relations are distrubuted to the relevant tasks before calculation.
00188     void clearProxyRelations();
00189     void addParentProxyRelations(QPtrList<Relation> &list);
00190     void addChildProxyRelations(QPtrList<Relation> &list);
00191     void addParentProxyRelation(Node *node, const Relation *rel);
00192     void addChildProxyRelation(Node *node, const Relation *rel);
00193     
00195     bool isEndNode() const;
00197     bool isStartNode() const;
00198     
00205     virtual DateTime workStartTime() const;
00206     
00213     virtual DateTime workEndTime() const;
00214     
00220     Duration positiveFloat();
00225     Duration negativeFloat() { return Duration(); }
00230     Duration freeFloat() { return Duration(); }
00234     Duration startFloat() { return Duration(); }
00240     Duration finishFloat() { return Duration(); }
00241     
00243     virtual bool isCritical();
00245     virtual bool calcCriticalPath(bool fromEnd);
00246     
00248     virtual void setCurrentSchedule(long id);
00249     
00250     struct Progress {
00251         Progress() { started = finished = false; percentFinished = 0; }
00252         bool operator==(struct Progress &p) {
00253             return started == p.started && finished == p.finished &&
00254                    startTime == p.startTime && finishTime == p.finishTime &&
00255                    percentFinished == p.percentFinished &&
00256                    remainingEffort == p.remainingEffort &&
00257                    totalPerformed == p.totalPerformed;
00258         }
00259         bool operator!=(struct Progress &p) { return !(*this == p); }
00260         struct Progress &operator=(struct Progress &p) {
00261             started = p.started; finished = p.finished;
00262             startTime = p.startTime; finishTime = p.finishTime;
00263             percentFinished = p.percentFinished;
00264             remainingEffort = p.remainingEffort;
00265             totalPerformed = p.totalPerformed;
00266             return *this;
00267         }
00268         bool started, finished;
00269         DateTime startTime, finishTime;
00270         int percentFinished;
00271         Duration remainingEffort;
00272         Duration totalPerformed;        
00273     };
00274     struct Progress &progress() { return m_progress; }
00275     
00276 private:
00277     DateTime calculateSuccessors(const QPtrList<Relation> &list, int use);
00278     DateTime calculatePredeccessors(const QPtrList<Relation> &list, int use);
00279     DateTime scheduleSuccessors(const QPtrList<Relation> &list, int use);
00280     DateTime schedulePredeccessors(const QPtrList<Relation> &list, int use);
00281     
00282     DateTime workStartAfter(const DateTime &dt);
00283     DateTime workFinishBefore(const DateTime &dt);
00284 
00285 private:
00286     QPtrList<ResourceGroup> m_resource;
00287 
00288     ResourceRequestCollection *m_requests;
00289  
00290     QPtrList<Relation> m_parentProxyRelations;
00291     QPtrList<Relation> m_childProxyRelations;
00292       
00293     struct Progress m_progress;
00294     
00295 #ifndef NDEBUG
00296 public:
00297     void printDebug(bool children, QCString indent);
00298 #endif
00299 
00300 };
00301 
00302 }  //KPlato namespace
00303 
00304 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys