BALL 1.5.0
Loading...
Searching...
No Matches
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

Type type_
 
bool negate_
 
ExpressionPredicatepredicate_
 
list< const ExpressionTree * > children_
 
void dump (std::ostream &is=std::cout, Size depth=0) const
 
bool compareChildren_ (const ExpressionTree &tree) const
 

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.

Member Enumeration Documentation

◆ Type

The type of an expression node in the tree. The type determines how a node is to be interpreted.

Enumerator
INVALID 

The node is invalid.

LEAF 

The node is a leaf.

OR 

The node is a logical OR conjunction.

AND 

The node is a logical AND conjunction.

Definition at line 38 of file expressionTree.h.

Constructor & Destructor Documentation

◆ ExpressionTree() [1/4]

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.

◆ ExpressionTree() [2/4]

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

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

◆ ExpressionTree() [3/4]

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

◆ ExpressionTree() [4/4]

BALL::ExpressionTree::ExpressionTree ( Type type,
list< const ExpressionTree * > children,
bool negate = false )

◆ ~ExpressionTree()

virtual BALL::ExpressionTree::~ExpressionTree ( )
virtual

Destructor

Member Function Documentation

◆ appendChild()

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

Append a child to the tree.

◆ clear()

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

Clear method

◆ compareChildren_()

bool BALL::ExpressionTree::compareChildren_ ( const ExpressionTree & tree) const
protected

◆ dump()

void BALL::ExpressionTree::dump ( std::ostream & is = std::cout,
Size depth = 0 ) const

◆ getChildren()

const list< const ExpressionTree * > & BALL::ExpressionTree::getChildren ( ) const

Get the list of children.

◆ getNegate()

bool BALL::ExpressionTree::getNegate ( ) const

Get the expression node's negation mode.

◆ getPredicate()

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

Get the predicate.

◆ getType()

Type BALL::ExpressionTree::getType ( ) const

Get the expression node's type

◆ operator!=()

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

Inequality operator

◆ operator()()

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

Evaluate the (sub)expression.

◆ operator=()

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

Asignment operator

◆ operator==()

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

Equality operator

◆ setNegate()

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

Set the expression node's negation mode.

◆ setPredicate()

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

Set the predicate.

◆ setType()

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

Set the expression node's type.

Member Data Documentation

◆ children_

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

Definition at line 180 of file expressionTree.h.

◆ negate_

bool BALL::ExpressionTree::negate_
protected

Definition at line 172 of file expressionTree.h.

◆ predicate_

ExpressionPredicate* BALL::ExpressionTree::predicate_
protected

Definition at line 176 of file expressionTree.h.

◆ type_

Type BALL::ExpressionTree::type_
protected

Definition at line 168 of file expressionTree.h.