OMNeT++ Simulation Library
5.6.1
|
#include <cdynamicexpression.h>
A stack-based expression evaluator class, for dynamically created expressions.
Classes | |
class | Elem |
One element in a (reverse Polish) expression. More... | |
class | Functor |
Function object base class. We use function objects to handle NED parameter references, "index" and "sizeof" operators, and references to NED "for" loop variables. More... | |
Public Types | |
enum | OpType |
Public Member Functions | |
Constructors, destructor, assignment. | |
cDynamicExpression () | |
cDynamicExpression (const cDynamicExpression &other) | |
virtual | ~cDynamicExpression () |
cDynamicExpression & | operator= (const cDynamicExpression &other) |
Redefined cObject functions | |
virtual cDynamicExpression * | dup () const override |
virtual std::string | str () const override |
Setter and evaluator methods. | |
virtual void | setExpression (Elem e[], int size) |
virtual cNedValue | evaluate (Context *context) const override |
virtual bool | boolValue (Context *context) const override |
virtual intpar_t | intValue (Context *context, const char *expectedUnit=nullptr) const override |
virtual double | doubleValue (Context *context, const char *expectedUnit=nullptr) const override |
virtual std::string | stringValue (Context *context) const override |
virtual cXMLElement * | xmlValue (Context *context) const override |
Public Member Functions inherited from cExpression | |
cExpression () | |
cExpression (const cExpression &other) | |
virtual | ~cExpression () |
cExpression & | operator= (const cExpression &other) |
virtual void | parsimPack (cCommBuffer *buffer) const override |
virtual void | parsimUnpack (cCommBuffer *buffer) override |
virtual cNedValue | evaluate (cComponent *contextComponent=nullptr) const |
virtual bool | boolValue (cComponent *contextComponent=nullptr) const |
virtual intpar_t | intValue (cComponent *contextComponent=nullptr, const char *expectedUnit=nullptr) const |
virtual double | doubleValue (cComponent *contextComponent=nullptr, const char *expectedUnit=nullptr) const |
virtual std::string | stringValue (cComponent *contextComponent=nullptr) const |
virtual cXMLElement * | xmlValue (cComponent *contextComponent=nullptr) const |
Public Member Functions inherited from cObject | |
cObject () | |
cObject (const cObject &other) | |
virtual | ~cObject () |
virtual const char * | getClassName () const |
virtual const char * | getName () const |
bool | isName (const char *s) const |
virtual const char * | getFullName () const |
virtual std::string | getFullPath () const |
const cObject * | getThisPtr () const |
virtual _OPPDEPRECATED std::string | info () const |
virtual _OPPDEPRECATED std::string | detailedInfo () const |
virtual cObject * | getOwner () const |
virtual bool | isOwnedObject () const |
virtual void | forEachChild (cVisitor *v) |
cObject * | findObject (const char *name, bool deep=true) |
void | copyNotSupported () const |
Miscellaneous utility functions. | |
virtual void | parse (const char *text) override |
virtual int | compare (const cExpression *other) const override |
virtual bool | isAConstant () const |
virtual bool | containsConstSubexpressions () const override |
virtual void | evaluateConstSubexpressions (Context *context) override |
static double | convertUnit (double d, const char *unit, const char *targetUnit) |
Additional Inherited Members | |
Protected Member Functions inherited from cObject | |
virtual void | take (cOwnedObject *obj) |
virtual void | drop (cOwnedObject *obj) |
void | dropAndDelete (cOwnedObject *obj) |
enum OpType |
Operations supported by this class:
|
explicit |
Constructor.
|
inline |
Copy constructor.
|
virtual |
Destructor.
cDynamicExpression& operator= | ( | const cDynamicExpression & | other | ) |
Assignment operator.
|
inlineoverridevirtual |
Creates and returns an exact copy of this object.
Reimplemented from cExpression.
References cExpression::boolValue(), cExpression::doubleValue(), cExpression::evaluate(), cExpression::intValue(), cExpression::stringValue(), and cExpression::xmlValue().
|
overridevirtual |
Converts the expression to string. See cObject for more details.
Reimplemented from cExpression.
|
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.
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.)
Implements cExpression.
|
overridevirtual |
Evaluate the expression and convert the result to bool if possible; throw an error if conversion from that type is not supported.
Implements cExpression.
|
overridevirtual |
Evaluate the expression and convert the result to intpar_t if possible; throw an error if conversion from that type is not supported, or the value of out of the range of intpar_t.
Implements cExpression.
|
overridevirtual |
Evaluate the expression and convert the result to double if possible; throw an error if conversion from that type is not supported.
Implements cExpression.
|
overridevirtual |
Evaluate the expression and convert the result to string if possible; throw an error if conversion from that type is not supported.
Implements cExpression.
|
overridevirtual |
Evaluate the expression and convert the result to an XML tree if possible; throw an error if conversion from that type is not supported.
Implements cExpression.
|
overridevirtual |
Interprets the string as an expression, and stores it.
Implements cExpression.
|
overridevirtual |
Compares two expressions.
Implements cExpression.
|
virtual |
Returns true if the expression is just a literal (or equivalent to one, like "2+2").
|
overridevirtual |
Returns true if this expression contains const subexpressions.
Implements cExpression.
|
overridevirtual |
Evaluates const subexpressions, and replaces them with their values. See cDynamicExpression::Elem::CONSTSUBEXPR.
Implements cExpression.
|
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).