/usr/include/BALL/KERNEL/expression.h is in libball1.4-dev 1.4.1+20111206-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | // -*- 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;
/** Expression class.
This class provides a frontend to ExpressionTree. \par
Expressions may be built from the following modules: \par
AND & a conjunction \par
OR & a disjunction \par
predicate(argument) & a predicate class that is derived from
\Ref{ExpressionPredicate) and provides <tt>operator () (const Atom& atom) const</tt>. \par
\par
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 ExpressionTree
\ingroup Predicates
*/
class BALL_EXPORT Expression
{
public:
BALL_CREATE(Expression)
/** @name Type Definitions
*/
//@{
/** A creation method for predicates.
*/
typedef void * (*CreationMethod) ();
//@}
/** @name Constructors and Destructor
*/
//@{
/** Default Constructor.
*/
Expression();
/** Copy Constructor.
*/
Expression(const Expression& expression);
/** Construct an Expression with a string
* @throw Exception::ParseError if a syntax error was encountered
*/
Expression(const String& expression_string);
/** Destructor.
*/
virtual ~Expression();
//@}
/** @name Predicates
*/
//@{
/**
*/
bool hasPredicate(const String& name) const;
/** Equality operator
*/
bool operator == (const Expression& expression) const;
//@}
/** @name Accessors
*/
//@{
/** Evaluate the expression of <tt>atom</tt>
@param atom
*/
virtual bool operator () (const Atom& atom) const;
/** Create a new predicate according to the name.
If the predicate is not known, return 0.
@param name the name of the predicate
@param args the optional argument of the predicate
*/
ExpressionPredicate* getPredicate(const String& name,
const String& args = "") const;
/** Register a new predicate class.
*/
void registerPredicate(const String& name, CreationMethod creation_method);
/** Set the expression and build a tree for it.
* @throw Exception::ParseError if a syntax error was encountered
*/
void setExpression(const String& expression);
/** Get the expression string.
*/
const String& getExpressionString() const;
/** Get the expression tree.
*/
const ExpressionTree* getExpressionTree() const;
/** Get the creation methods.
*/
const StringHashMap<CreationMethod>& getCreationMethods() const;
//@}
/** @name Assignment
*/
//@{
/** Assignment operator
*/
Expression& operator = (const Expression& expression);
/** Clear method
*/
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
|