BALL  1.4.79
Protected Member Functions | Protected Attributes | List of all members
BALL::ExpressionTree Class Reference

#include <BALL/KERNEL/expressionTree.h>

Public Types

Type Definitions
enum  Type { INVALID = 0, LEAF, OR, AND }
 

Public Member Functions

Constructors and Destructor
 ExpressionTree ()
 
 ExpressionTree (const ExpressionTree &tree)
 
 ExpressionTree (ExpressionPredicate *predicate, bool negate=false)
 
 ExpressionTree (Type type, list< const ExpressionTree * > children, bool negate=false)
 
virtual ~ExpressionTree ()
 
Predicates
virtual bool operator() (const Atom &atom) const
 
bool operator== (const ExpressionTree &tree) const
 
bool operator!= (const ExpressionTree &tree) const
 
Accessors
void setType (Type type)
 
Type getType () const
 
void setNegate (bool negate)
 
bool getNegate () const
 
void setPredicate (ExpressionPredicate *predicate)
 
ExpressionPredicategetPredicate () const
 
void appendChild (const ExpressionTree *child)
 
const list< const ExpressionTree * > & getChildren () const
 
Assignment
ExpressionTreeoperator= (const ExpressionTree &tree)
 
virtual void clear ()
 
Debugging
void dump (std::ostream &is=std::cout, Size depth=0) const
 

Protected Member Functions

bool compareChildren_ (const ExpressionTree &tree) const
 

Protected Attributes

Type type_
 
bool negate_
 
ExpressionPredicatepredicate_
 
list< const ExpressionTree * > children_
 

Detailed Description

Expression tree class. Represents the logical tree of an Expression. This is the backend of Expression.

See also
Expression

Definition at line 25 of file expressionTree.h.

Constructor & Destructor Documentation

BALL::ExpressionTree::ExpressionTree ( )

Default constructor. Create an empty expression node. The node's type is set to INVALID, negate_ is set to false, the internal predicate is set to 0, and the list of children is empty.

BALL::ExpressionTree::ExpressionTree ( const ExpressionTree tree)

Copy constructor. Note that this copy constructor does not copy predicates but only stores pointers to them.

BALL::ExpressionTree::ExpressionTree ( ExpressionPredicate predicate,
bool  negate = false 
)

Detailed constructor. Create an expression node representing a leaf, i.e., a predicate.

Parameters
predicatethe node's predicate
negateset to true if the node's predicate should be negated
BALL::ExpressionTree::ExpressionTree ( Type  type,
list< const ExpressionTree * >  children,
bool  negate = false 
)
virtual BALL::ExpressionTree::~ExpressionTree ( )
virtual

Destructor

Member Function Documentation

void BALL::ExpressionTree::appendChild ( const ExpressionTree child)

Append a child to the tree.

virtual void BALL::ExpressionTree::clear ( )
virtual

Clear method

bool BALL::ExpressionTree::compareChildren_ ( const ExpressionTree tree) const
protected
void BALL::ExpressionTree::dump ( std::ostream &  is = std::cout,
Size  depth = 0 
) const
const list<const ExpressionTree*>& BALL::ExpressionTree::getChildren ( ) const

Get the list of children.

bool BALL::ExpressionTree::getNegate ( ) const

Get the expression node's negation mode.

ExpressionPredicate* BALL::ExpressionTree::getPredicate ( ) const

Get the predicate.

Type BALL::ExpressionTree::getType ( ) const

Get the expression node's type

bool BALL::ExpressionTree::operator!= ( const ExpressionTree tree) const

Inequality operator

virtual bool BALL::ExpressionTree::operator() ( const Atom atom) const
virtual

Evaluate the (sub)expression.

ExpressionTree& BALL::ExpressionTree::operator= ( const ExpressionTree tree)

Asignment operator

bool BALL::ExpressionTree::operator== ( const ExpressionTree tree) const

Equality operator

void BALL::ExpressionTree::setNegate ( bool  negate)

Set the expression node's negation mode.

void BALL::ExpressionTree::setPredicate ( ExpressionPredicate predicate)

Set the predicate.

void BALL::ExpressionTree::setType ( Type  type)

Set the expression node's type.

Member Data Documentation

list<const ExpressionTree*> BALL::ExpressionTree::children_
protected

Definition at line 180 of file expressionTree.h.

bool BALL::ExpressionTree::negate_
protected

Definition at line 172 of file expressionTree.h.

ExpressionPredicate* BALL::ExpressionTree::predicate_
protected

Definition at line 176 of file expressionTree.h.

Type BALL::ExpressionTree::type_
protected

Definition at line 168 of file expressionTree.h.