OSDN Git Service

fix compile problem
[tjqt4port/tj2qt4.git] / taskjuggler / Operation.h
1 /*
2  * Operation.h - TaskJuggler
3  *
4  * Copyright (c) 2001, 2002, 2003, 2004 by Chris Schlaeger <cs@kde.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of version 2 of the GNU General Public License as
8  * published by the Free Software Foundation.
9  *
10  * $Id$
11  */
12
13 #ifndef _Operation_h_
14 #define _Operation_h_
15
16 #include <time.h>
17
18 #include <qstring.h>
19 #include <q3ptrlist.h>
20
21 class QString;
22
23 class ExpressionTree;
24 class Operation;
25
26 class Operation
27 {
28 public:
29     enum opType { Const = 1, Variable, Function, Id, Date, String,
30         Not, And, Or,
31         Greater, Smaller, Equal, GreaterOrEqual, SmallerOrEqual };
32
33     Operation(long v) :
34         opt(Const),
35         value(v),
36         name(),
37         ops(0),
38         opsCount(0),
39         valid(false)
40     { }
41
42     Operation(opType ot, const QString& n) :
43         opt(ot),
44         value(0),
45         name(n),
46         ops(0),
47         opsCount(0),
48         valid(false)
49     { }
50
51     Operation(opType ot, long v) :
52         opt(ot),
53         value(v),
54         name(),
55         ops(0),
56         opsCount(0),
57         valid(false)
58     { }
59
60     Operation(opType ot, const QString& n, long v) :
61         opt(ot),
62         value(v),
63         name(n),
64         ops(0),
65         opsCount(0),
66         valid(false)
67     { }
68
69     Operation(const QString& v) :
70         opt(Variable),
71         value(0),
72         name(v),
73         ops(0),
74         opsCount(0),
75         valid(false)
76     { }
77
78     Operation(Operation* o1, opType ot, Operation* o2 = 0) :
79         opt(ot),
80         value(0),
81         name(),
82         ops(new Operation*[2]),
83         opsCount(2),
84         valid(false)
85     {
86         ops[0] = o1;
87         ops[1] = o2;
88
89     }
90     Operation(const QString& n, Operation* o1) :
91         opt(Function),
92         value(0),
93         name(n),
94         ops(new Operation*[1]),
95         opsCount(1),
96         valid(false)
97     {
98         ops[0] = o1;
99     }
100
101     Operation(const QString& n, Operation* o1, Operation* o2) :
102         opt(Function),
103         value(0),
104         name(n),
105         ops(new Operation*[2]),
106         opsCount(2),
107         valid(false)
108     {
109         ops[0] = o1;
110         ops[1] = o2;
111     }
112
113     Operation(const QString& n, Operation* args[], int c) :
114         opt(Function),
115         value(0),
116         name(n),
117         ops(args),
118         opsCount(c),
119         valid(false)
120     { }
121
122     Operation(const Operation& op);
123
124     ~Operation();
125
126     long evalAsInt(ExpressionTree* et) const;
127     time_t evalAsTime(ExpressionTree* et) const;
128     QString evalAsString(ExpressionTree* et) const;
129
130     void setValid(bool v = true)
131     {
132         valid = v;
133     }
134     bool isValid() const { return valid; }
135
136     QString debugString();
137
138 private:
139     long evalFunction(ExpressionTree* et) const;
140     QString evalFunctionAsString(ExpressionTree* et) const;
141
142     opType opt;
143     long value;
144     QString name;
145     Operation** ops;
146     int opsCount;
147     bool valid;
148 } ;
149
150 #endif
151