OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Expression Class Reference

Expression to be evaluated in the framework. More...

#include <Expression.h>

Collaboration diagram for Expression:
Collaboration graph
[legend]

Public Member Functions

 Expression ()
 
 Expression (std::string expr)
 
 Expression (std::string expr, functionDictionary_t known_expr_funcs)
 
virtual ~Expression ()
 
std::set< std::string > getReqVars () const
 
std::set< std::string > getReqFuncs () const
 
std::string toString () const
 
functionDictionary_t getRegFuncs () const
 
Expressions::OperatorType_t getOpType () const
 get operator type present (if expression is constraint) More...
 
Expressions::Result_t evaluate (variableDictionary_t vars)
 evaluate an expression given a value dictionary of free variables More...
 

Private Types

typedef std::string::const_iterator iterator_type
 

Private Member Functions

void determineConstrOperator ()
 
void parse ()
 

Private Attributes

client::ast::expression ast_
 
std::set< std::string > vars_
 
std::set< std::string > funcs_
 
std::string expr_
 
functionDictionary_t known_expr_funcs_
 
Expressions::OperatorType_t type_
 

Detailed Description

Expression to be evaluated in the framework.

See Also
GlobalFunctions.h

This class uses the Boost Spirit parser to parse and evaluate string expressions (objectives or constraints). Custom functions called in the expression should be registered by the driver. A collection of C math default functions is always included. For constraints the operator type can be queried.

Definition at line 75 of file Expression.h.

Member Typedef Documentation

typedef std::string::const_iterator Expression::iterator_type
private

Definition at line 136 of file Expression.h.

Constructor & Destructor Documentation

Expression::Expression ( )
inline

Definition at line 79 of file Expression.h.

Expression::Expression ( std::string  expr)
inline

Definition at line 82 of file Expression.h.

References determineConstrOperator(), known_expr_funcs_, and parse().

Here is the call graph for this function:

Expression::Expression ( std::string  expr,
functionDictionary_t  known_expr_funcs 
)
inline

Definition at line 91 of file Expression.h.

References determineConstrOperator(), known_expr_funcs_, and parse().

Here is the call graph for this function:

virtual Expression::~Expression ( )
inlinevirtual

Definition at line 101 of file Expression.h.

Member Function Documentation

void Expression::determineConstrOperator ( )
inlineprivate
Expressions::Result_t Expression::evaluate ( variableDictionary_t  vars)
inline

evaluate an expression given a value dictionary of free variables

Definition at line 114 of file Expression.h.

References ast_, expr_, known_expr_funcs_, client::code_gen::StackEvaluator::registerFunctions(), client::code_gen::StackEvaluator::registerVariables(), and client::code_gen::StackEvaluator::result().

Referenced by Individual::checkConstraints(), and OpalSimulation::collectResults().

Here is the call graph for this function:

Expressions::OperatorType_t Expression::getOpType ( ) const
inline

get operator type present (if expression is constraint)

Definition at line 111 of file Expression.h.

References type_.

functionDictionary_t Expression::getRegFuncs ( ) const
inline

Definition at line 108 of file Expression.h.

References known_expr_funcs_.

Referenced by OpalSimulation::collectResults().

std::set<std::string> Expression::getReqFuncs ( ) const
inline

Definition at line 106 of file Expression.h.

References funcs_.

std::set<std::string> Expression::getReqVars ( ) const
inline

Definition at line 105 of file Expression.h.

References vars_.

Referenced by Individual::checkConstraints(), and OpalSimulation::getVariableDictionary().

void Expression::parse ( )
inlineprivate

Definition at line 167 of file Expression.h.

References ast_, endl(), expr_, funcs_, client::code_gen::requirements::functions(), client::code_gen::requirements::variables(), and vars_.

Referenced by Expression().

Here is the call graph for this function:

std::string Expression::toString ( ) const
inline

Definition at line 107 of file Expression.h.

References expr_.

Referenced by OpalSimulation::collectResults().

Member Data Documentation

client::ast::expression Expression::ast_
private

Definition at line 137 of file Expression.h.

Referenced by evaluate(), and parse().

std::string Expression::expr_
private

Definition at line 142 of file Expression.h.

Referenced by determineConstrOperator(), evaluate(), parse(), and toString().

std::set<std::string> Expression::funcs_
private

Definition at line 140 of file Expression.h.

Referenced by getReqFuncs(), and parse().

functionDictionary_t Expression::known_expr_funcs_
private

Definition at line 143 of file Expression.h.

Referenced by evaluate(), Expression(), and getRegFuncs().

Expressions::OperatorType_t Expression::type_
private

Definition at line 145 of file Expression.h.

Referenced by determineConstrOperator(), and getOpType().

std::set<std::string> Expression::vars_
private

Definition at line 139 of file Expression.h.

Referenced by getReqVars(), and parse().


The documentation for this class was generated from the following file: