Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

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

Protected Member Functions

ExpressionTreeconstructExpressionTree_ (const ExpressionParser::SyntaxTree &tree) throw (Exception::ParseError)
void registerStandardPredicates_ () throw ()

Protected Attributes

StringHashMap< CreationMethodcreate_methods_
ExpressionTreeexpression_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 Typedef Documentation

typedef void*(* Expression::CreationMethod)()
 

A creation method for predicates.


Constructor & Destructor Documentation

Expression::Expression  )  throw ()
 

Default Constructor.

Expression::Expression const Expression expression  )  throw ()
 

Copy Constructor.

virtual Expression::~Expression  )  throw () [virtual]
 

Destructor.


Member Function Documentation

const StringHashMap<CreationMethod>& Expression::getCreationMethods  )  const throw ()
 

Get the creation methods.

const String& Expression::getExpressionString  )  const throw ()
 

Get the expression string.

const ExpressionTree* Expression::getExpressionTree  )  const throw ()
 

Get the expression tree.

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

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 Expression::operator() const Atom atom  )  const throw () [virtual]
 

Evaluate the expression of atom.

Parameters:
atom 

void Expression::registerPredicate const String name,
CreationMethod  creation_method
throw ()
 

Register a new predicate class.

void Expression::setExpression const String expression  )  throw (Exception::ParseError)
 

Set the expression and build a tree for it.