Loading...
Searching...
No Matches
expression.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_KERNEL_EXPRESSION_H
#define BALL_KERNEL_EXPRESSION_H
#ifndef BALL_DATATYPE_STRINGHASHMAP_H
# include <BALL/DATATYPE/stringHashMap.h>
#endif
#ifndef BALL_KERNEL_EXPRESSIONPARSER_H
# include <BALL/KERNEL/expressionParser.h>
#endif
namespace BALL
{
class Atom;
class ExpressionTree;
class BALL_EXPORT Expression
{
public:
BALL_CREATE(Expression)
typedef void * (*CreationMethod) ();
Expression();
Expression(const Expression& expression);
Expression(const String& expression_string);
virtual ~Expression();
bool hasPredicate(const String& name) const;
bool operator == (const Expression& expression) const;
virtual bool operator () (const Atom& atom) const;
ExpressionPredicate* getPredicate(const String& name,
const String& args = "") const;
void registerPredicate(const String& name, CreationMethod creation_method);
void setExpression(const String& expression);
const String& getExpressionString() const;
const ExpressionTree* getExpressionTree() const;
const StringHashMap<CreationMethod>& getCreationMethods() const;
Expression& operator = (const Expression& expression);
virtual void clear();
protected:
/*_ @name Protected methods
*/
/*_ Construct the expression tree from the SyntaxTree
* @throw Exception::ParseError if a syntax error was encountered
*/
ExpressionTree* constructExpressionTree_(const ExpressionParser::SyntaxTree& tree);
/*_ Register the predicates defined by default.
See also: BALL/KERNEL/standardPredicates.h
*/
void registerStandardPredicates_();
/*_ @name Protected attributes
*/
/*_ The methods to create the ExpressionPredicate instances
*/
StringHashMap<CreationMethod> create_methods_;
/*_ The ExpressionTree constructed from the string.
This tree contains the instances of the predicates.
*/
ExpressionTree* expression_tree_;
/*_ The string describing the expression.
*/
String expression_string_;
};
}
#endif // BALL_KERNEL_EXPRESSION_H
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::Atom
Definition atom.h:90
BALL::ExpressionParser
Definition expressionParser.h:23
BALL::ExpressionPredicate
Definition expressionPredicate.h:27
BALL::ExpressionTree
Definition expressionTree.h:26
BALL::Expression::Expression
Expression()
BALL::Expression::setExpression
void setExpression(const String &expression)
BALL::Expression::getPredicate
ExpressionPredicate * getPredicate(const String &name, const String &args="") const
BALL::Expression::getCreationMethods
const StringHashMap< CreationMethod > & getCreationMethods() const
BALL::Expression::clear
virtual void clear()
BALL::Expression::constructExpressionTree_
ExpressionTree * constructExpressionTree_(const ExpressionParser::SyntaxTree &tree)
BALL::Expression::expression_tree_
ExpressionTree * expression_tree_
Definition expression.h:210
BALL::Expression::getExpressionString
const String & getExpressionString() const
BALL::Expression::getExpressionTree
const ExpressionTree * getExpressionTree() const
BALL::Expression::CreationMethod
void *(* CreationMethod)()
Definition expression.h:91
BALL::Expression::expression_string_
String expression_string_
Definition expression.h:214
BALL::Expression::create_methods_
StringHashMap< CreationMethod > create_methods_
Definition expression.h:205
BALL::Expression::hasPredicate
bool hasPredicate(const String &name) const
BALL::Expression::registerStandardPredicates_
void registerStandardPredicates_()
BALL::Expression::registerPredicate
void registerPredicate(const String &name, CreationMethod creation_method)
BALL::StringHashMap
Definition stringHashMap.h:42
BALL::String
Definition string.h:57
BALL_CREATE
#define BALL_CREATE(name)
Definition create.h:62
expressionParser.h
BALL
Definition constants.h:13
stringHashMap.h