cDynamicExpression Class Reference
[Simulation core classes]

A stack-based expression evaluator class, for dynamically created expressions. More...

#include <cdynamicexpression.h>

Inheritance diagram for cDynamicExpression:
cExpression cObject

List of all members.

Classes

class  Elem
 One element in a (reverse Polish) expression. More...
class  Functor
 Function object base class. More...

Public Types

enum  OpType

Public Member Functions

Constructors, destructor, assignment.

 cDynamicExpression ()
 cDynamicExpression (const cDynamicExpression &other)
virtual ~cDynamicExpression ()
cDynamicExpressionoperator= (const cDynamicExpression &other)
Redefined cObject functions

virtual cDynamicExpressiondup () const
virtual std::string info () const
Setter and evaluator methods.

virtual void setExpression (Elem e[], int size)
virtual cNEDValue evaluate (cComponent *context) const
virtual bool boolValue (cComponent *context)
virtual long longValue (cComponent *context, const char *expectedUnit=NULL)
virtual double doubleValue (cComponent *context, const char *expectedUnit=NULL)
virtual std::string stringValue (cComponent *context)
virtual cXMLElementxmlValue (cComponent *context)

Miscellaneous utility functions.



virtual std::string str () const
virtual void parse (const char *text)
virtual int compare (const cExpression *other) const
virtual bool isAConstant () const
virtual bool containsConstSubexpressions () const
virtual void evaluateConstSubexpressions (cComponent *context)
static double convertUnit (double d, const char *unit, const char *targetUnit)

Detailed Description

A stack-based expression evaluator class, for dynamically created expressions.

NOTE: Experimental class -- API is subject to change.


Member Function Documentation

static double cDynamicExpression::convertUnit ( double  d,
const char *  unit,
const char *  targetUnit 
) [static]

Convert the given number into the target unit (e.g.

milliwatt to watt). Throws an exception if conversion is not possible (unknown/unrelated units).

Referenced by cNEDValue::doubleValueInUnit().

virtual cNEDValue cDynamicExpression::evaluate ( cComponent context  )  const [virtual]

Evaluate the expression, and return the results as a cNEDValue.

Throws an error if the expression has some problem (i.e. stack overflow/underflow, "cannot cast", "function not found", etc.)

Reimplemented from cExpression.

virtual void cDynamicExpression::evaluateConstSubexpressions ( cComponent context  )  [virtual]

Evaluates const subexpressions, and replaces them with their values.

See cDynamicExpression::Elem::CONSTSUBEXPR.

Implements cExpression.

virtual std::string cDynamicExpression::info (  )  const [virtual]

Produces a one-line description of the object's contents.

See cObject for more details.

Reimplemented from cExpression.

virtual void cDynamicExpression::setExpression ( Elem  e[],
int  size 
) [virtual]

Sets the Reverse Polish expression to evaluate.

The array must be a dynamically allocated one, and will be deleted by this object. No verification is performed on the expression at this time.


The documentation for this class was generated from the following file:
Generated on Tue Dec 2 11:16:28 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3