BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
expressionTree.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 // $Id: expressionTree.h,v 1.12 2005/10/23 12:02:18 oliver Exp $
5 //
6 
7 #ifndef BALL_KERNEL_EXPRESSIONTREE_H
8 #define BALL_KERNEL_EXPRESSIONTREE_H
9 
10 #ifndef BALL_KERNEL_EXPRESSIONPREDICATE_H
12 #endif
13 
14 namespace BALL
15 {
16 
26  {
27  public:
28 
30 
31 
34 
38  enum Type
39  {
41  INVALID = 0,
45  OR,
47  AND
48  };
50 
54 
61 
65  ExpressionTree(const ExpressionTree& tree);
66 
74  ExpressionTree(ExpressionPredicate* predicate, bool negate = false);
75 
78  ExpressionTree(Type type, list<const ExpressionTree*> children, bool negate = false);
79 
82  virtual ~ExpressionTree();
83 
85 
88 
91  virtual bool operator () (const Atom& atom) const;
92 
95  bool operator == (const ExpressionTree& tree) const;
96 
99  bool operator != (const ExpressionTree& tree) const;
100 
102 
105 
108  void setType(Type type) ;
109 
112  Type getType() const;
113 
116  void setNegate(bool negate);
117 
120  bool getNegate() const;
121 
124  void setPredicate(ExpressionPredicate* predicate);
125 
128  ExpressionPredicate* getPredicate() const;
129 
132  void appendChild(const ExpressionTree* child);
133 
136  const list<const ExpressionTree*>& getChildren() const;
137 
139 
142 
145  ExpressionTree& operator = (const ExpressionTree& tree);
146 
149  virtual void clear();
150 
152 
155  void dump(std::ostream& is = std::cout, Size depth = 0) const;
157 
158 
159  protected:
160 
161  /*_ A helper function for operator == () that compares the children of
162  a node.
163  */
164  bool compareChildren_(const ExpressionTree& tree) const;
165 
166  /*_ The type of this node.
167  */
169 
170  /*_ Negation flag. If set, the value of this node will be negated.
171  */
172  bool negate_;
173 
174  /*_ A pointer to the predicate that this node represents.
175  */
177 
178  /*_ A list containing pointers to the children of this node.
179  */
180  list<const ExpressionTree*> children_;
181 
182  };
183 
184 }
185 
186 #endif // BALL_KERNEL_EXPRESSIONTREE_H