BALL::Expression Class Reference
[Kernel Predicates]

Expression class. More...

#include <expression.h>

List of all members.


Public Types

Type Definitions
typedef void *(* CreationMethod )()
A creation method for predicates.

Public Member Functions

Constructors and Destructor
Expression ()
Default Constructor.
Expression (const Expression &expression)
Copy Constructor.
Expression (const String &expression_string) throw (Exception::ParseError)
Construct an Expression with a string.
virtual ~Expression ()
Destructor.
Predicates
bool hasPredicate (const String &name) const
bool operator== (const Expression &expression) const
Equality operator.
Accessors
virtual bool operator() (const Atom &atom) const
Evaluate the expression of atom.
ExpressionPredicate * getPredicate (const String &name, const String &args="") const
Create a new predicate according to the name.
void registerPredicate (const String &name, CreationMethod creation_method)
Register a new predicate class.
void setExpression (const String &expression) throw (Exception::ParseError)
Set the expression and build a tree for it.
const String & getExpressionString () const
Get the expression string.
const ExpressionTree * getExpressionTree () const
Get the expression tree.
const StringHashMap
< CreationMethod > &
getCreationMethods () const
Get the creation methods.
Assignment
Expression & operator= (const Expression &expression)
Assignment operator.
virtual void clear ()
Clear method.

Protected Member Functions

ExpressionTree * constructExpressionTree_ (const ExpressionParser::SyntaxTree &tree) throw (Exception::ParseError)
void registerStandardPredicates_ ()

Protected Attributes

StringHashMap< CreationMethod > create_methods_
ExpressionTree * expression_tree_
String expression_string_

Detailed Description

Expression class.

This class provides a frontend to ExpressionTree.

Expressions may be built from the following modules:
AND & a conjunction
OR & a disjunction
predicate(argument) & a predicate class that is derived from {ExpressionPredicate) and provides operator () (const Atom& atom) const.
Additionally brackets can be used for grouping. At least one bracket pair must exist which encloses the argument of a predicate. Empty arguments are allowed.
See also:
ExpressionTree

Member Function Documentation

ExpressionPredicate* BALL::Expression::getPredicate ( const String & name,
const String & args = ""
) const

Create a new predicate according to the name.

If the predicate is not known, return 0.

Parameters:
name the name of the predicate
args the optional argument of the predicate

virtual bool BALL::Expression::operator() ( const Atom & atom ) const [virtual]

Evaluate the expression of atom.

Parameters:
atom

Generated on Thu Aug 6 18:30:31 2009 for BALL by doxygen 1.5.8