00001
00002
00003
00004
00005
00006
00007 #ifndef BALL_KERNEL_EXPRESSIONTREE_H
00008 #define BALL_KERNEL_EXPRESSIONTREE_H
00009
00010 #ifndef BALL_KERNEL_EXPRESSIONPREDICATE_H
00011 # include <BALL/KERNEL/expressionPredicate.h>
00012 #endif
00013
00014 namespace BALL
00015 {
00016
00025 class BALL_EXPORT ExpressionTree
00026 {
00027 public:
00028
00029 BALL_CREATE(ExpressionTree)
00030
00031
00034
00038 enum Type
00039 {
00041 INVALID = 0,
00043 LEAF,
00045 OR,
00047 AND
00048 };
00050
00054
00060 ExpressionTree();
00061
00065 ExpressionTree(const ExpressionTree& tree);
00066
00074 ExpressionTree(ExpressionPredicate* predicate, bool negate = false);
00075
00078 ExpressionTree(Type type, list<const ExpressionTree*> children, bool negate = false);
00079
00082 virtual ~ExpressionTree();
00083
00085
00088
00091 virtual bool operator () (const Atom& atom) const;
00092
00095 bool operator == (const ExpressionTree& tree) const;
00096
00099 bool operator != (const ExpressionTree& tree) const;
00100
00102
00105
00108 void setType(Type type) ;
00109
00112 Type getType() const;
00113
00116 void setNegate(bool negate);
00117
00120 bool getNegate() const;
00121
00124 void setPredicate(ExpressionPredicate* predicate);
00125
00128 ExpressionPredicate* getPredicate() const;
00129
00132 void appendChild(const ExpressionTree* child);
00133
00136 const list<const ExpressionTree*>& getChildren() const;
00137
00139
00142
00145 ExpressionTree& operator = (const ExpressionTree& tree);
00146
00149 virtual void clear();
00150
00152
00155 void dump(std::ostream& is = std::cout, Size depth = 0) const;
00157
00158
00159 protected:
00160
00161
00162
00163
00164 bool compareChildren_(const ExpressionTree& tree) const;
00165
00166
00167
00168 Type type_;
00169
00170
00171
00172 bool negate_;
00173
00174
00175
00176 ExpressionPredicate* predicate_;
00177
00178
00179
00180 list<const ExpressionTree*> children_;
00181
00182 };
00183
00184 }
00185
00186 #endif // BALL_KERNEL_EXPRESSIONTREE_H