kplato

kptrelation.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 KPTRELATION_H
22#define KPTRELATION_H
23
24#include "kptduration.h"
25
26#include <tqstring.h>
27
28class TQCanvas;
29class TQDomElement;
30
31namespace KPlato
32{
33
34class Node;
35class Project;
36class PertCanvas;
37
45class Relation {
46public:
47 enum Type { FinishStart, FinishFinish, StartStart };
48
49 Relation(Node *parent, Node *child, Type type, Duration lag);
50 Relation(Node *parent=0, Node *child=0, Type type=FinishStart);
51 Relation(Relation *rel);
52
57 virtual ~Relation();
58
59 void setType(Type );
60 Type type() const { return m_type; }
61
66 const Duration &lag() const { return m_lag; }
67 void setLag(Duration lag) { m_lag = lag; }
68
72 Node *parent() const { return m_parent; }
76 Node *child() const { return m_child; }
77
78 enum Result {
79 SUCCESS = 0l,
80 HASCHILDREN = 1l,
81 NOTIMPL = 2l
82 };
83
84 bool load(TQDomElement &element, Project &project);
85 void save(TQDomElement &element) const;
86
87protected: // variables
88 Node *m_parent;
89 Node *m_child;
90 Type m_type;
91 Duration m_lag;
92
93private:
94 TQString m_parentId;
95
96#ifndef NDEBUG
97public:
98 void printDebug(TQCString indent);
99#endif
100
101};
102
103class ProxyRelation : public Relation
104{
105public:
106 ProxyRelation(Node *parent, Node *child, Relation::Type type, Duration lag)
107 : Relation(parent, child, type, lag)
108 {}
109
110 ~ProxyRelation() { m_parent = 0; m_child = 0;}
111};
112
113} //KPlato namespace
114
115#endif
The duration class can be used to store a timespan in a convenient format.
Definition kptduration.h:34
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
The relation class couples a 2 nodes together which are dependent on each other.
Definition kptrelation.h:45
Node * parent() const
Definition kptrelation.h:72
const Duration & lag() const
returns the lag.
Definition kptrelation.h:66
virtual ~Relation()
When deleted the relation will remove itself from the parent- and child nodes lists.
Node * child() const
Definition kptrelation.h:76