Loading...
Searching...
No Matches
expressionTree.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: expressionTree.h,v 1.12 2005/10/23 12:02:18 oliver Exp $
//
#ifndef BALL_KERNEL_EXPRESSIONTREE_H
#define BALL_KERNEL_EXPRESSIONTREE_H
#ifndef BALL_KERNEL_EXPRESSIONPREDICATE_H
# include <BALL/KERNEL/expressionPredicate.h>
#endif
namespace BALL
{
class BALL_EXPORT ExpressionTree
{
public:
BALL_CREATE(ExpressionTree)
enum Type
{
INVALID = 0,
LEAF,
OR,
AND
};
ExpressionTree();
ExpressionTree(const ExpressionTree& tree);
ExpressionTree(ExpressionPredicate* predicate, bool negate = false);
ExpressionTree(Type type, list<const ExpressionTree*> children, bool negate = false);
virtual ~ExpressionTree();
virtual bool operator () (const Atom& atom) const;
bool operator == (const ExpressionTree& tree) const;
bool operator != (const ExpressionTree& tree) const;
void setType(Type type) ;
Type getType() const;
void setNegate(bool negate);
bool getNegate() const;
void setPredicate(ExpressionPredicate* predicate);
ExpressionPredicate* getPredicate() const;
void appendChild(const ExpressionTree* child);
const list<const ExpressionTree*>& getChildren() const;
ExpressionTree& operator = (const ExpressionTree& tree);
virtual void clear();
void dump(std::ostream& is = std::cout, Size depth = 0) const;
protected:
/*_ A helper function for operator == () that compares the children of
a node.
*/
bool compareChildren_(const ExpressionTree& tree) const;
/*_ The type of this node.
*/
Type type_;
/*_ Negation flag. If set, the value of this node will be negated.
*/
bool negate_;
/*_ A pointer to the predicate that this node represents.
*/
ExpressionPredicate* predicate_;
/*_ A list containing pointers to the children of this node.
*/
list<const ExpressionTree*> children_;
};
}
#endif // BALL_KERNEL_EXPRESSIONTREE_H
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::Atom
Definition atom.h:90
BALL::ExpressionPredicate
Definition expressionPredicate.h:27
BALL::ExpressionTree::setType
void setType(Type type)
BALL::ExpressionTree::clear
virtual void clear()
BALL::ExpressionTree::ExpressionTree
ExpressionTree()
BALL::ExpressionTree::ExpressionTree
ExpressionTree(Type type, list< const ExpressionTree * > children, bool negate=false)
BALL::ExpressionTree::dump
void dump(std::ostream &is=std::cout, Size depth=0) const
BALL::ExpressionTree::type_
Type type_
Definition expressionTree.h:168
BALL::ExpressionTree::setNegate
void setNegate(bool negate)
BALL::ExpressionTree::negate_
bool negate_
Definition expressionTree.h:172
BALL::ExpressionTree::~ExpressionTree
virtual ~ExpressionTree()
BALL::ExpressionTree::appendChild
void appendChild(const ExpressionTree *child)
BALL::ExpressionTree::getType
Type getType() const
BALL::ExpressionTree::Type
Type
Definition expressionTree.h:39
BALL::ExpressionTree::LEAF
@ LEAF
The node is a leaf.
Definition expressionTree.h:43
BALL::ExpressionTree::AND
@ AND
The node is a logical AND conjunction.
Definition expressionTree.h:47
BALL::ExpressionTree::OR
@ OR
The node is a logical OR conjunction.
Definition expressionTree.h:45
BALL::ExpressionTree::INVALID
@ INVALID
The node is invalid.
Definition expressionTree.h:41
BALL::ExpressionTree::compareChildren_
bool compareChildren_(const ExpressionTree &tree) const
BALL::ExpressionTree::getPredicate
ExpressionPredicate * getPredicate() const
BALL::ExpressionTree::getNegate
bool getNegate() const
BALL::ExpressionTree::children_
list< const ExpressionTree * > children_
Definition expressionTree.h:180
BALL::ExpressionTree::setPredicate
void setPredicate(ExpressionPredicate *predicate)
BALL::ExpressionTree::getChildren
const list< const ExpressionTree * > & getChildren() const
BALL::ExpressionTree::ExpressionTree
ExpressionTree(const ExpressionTree &tree)
BALL::ExpressionTree::ExpressionTree
ExpressionTree(ExpressionPredicate *predicate, bool negate=false)
BALL::ExpressionTree::predicate_
ExpressionPredicate * predicate_
Definition expressionTree.h:176
BALL_CREATE
#define BALL_CREATE(name)
Definition create.h:62
expressionPredicate.h
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114