OMNeT++ Simulation Library  5.6.1
cExpression Class Referenceabstract

#include <cexpression.h>

Description

Abstract base class for expression evaluators.

See also
cPar
Inheritance diagram for cExpression:
cObject cDynamicExpression

Classes

class  Context
 Contextual information for evaluating the expression. More...
 

Public Member Functions

Constructors, destructor, assignment.
 cExpression ()
 
 cExpression (const cExpression &other)
 
virtual ~cExpression ()
 
cExpressionoperator= (const cExpression &other)
 
Redefined cObject functions
virtual cExpressiondup () const override
 
virtual std::string str () const override
 
virtual void parsimPack (cCommBuffer *buffer) const override
 
virtual void parsimUnpack (cCommBuffer *buffer) override
 
Evaluator methods.
virtual cNedValue evaluate (Context *context) const =0
 
virtual bool boolValue (Context *context) const =0
 
virtual intpar_t intValue (Context *context, const char *expectedUnit=nullptr) const =0
 
virtual double doubleValue (Context *context, const char *expectedUnit=nullptr) const =0
 
virtual std::string stringValue (Context *context) const =0
 
virtual cXMLElementxmlValue (Context *context) const =0
 
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 cXMLElementxmlValue (cComponent *contextComponent=nullptr) const
 
Miscellaneous utility functions.
virtual void parse (const char *text)=0
 
virtual int compare (const cExpression *other) const =0
 
virtual bool containsConstSubexpressions () const =0
 
virtual void evaluateConstSubexpressions (Context *context)=0
 
- 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 cObjectgetThisPtr () const
 
virtual _OPPDEPRECATED std::string info () const
 
virtual _OPPDEPRECATED std::string detailedInfo () const
 
virtual cObjectgetOwner () const
 
virtual bool isOwnedObject () const
 
virtual void forEachChild (cVisitor *v)
 
cObjectfindObject (const char *name, bool deep=true)
 
void copyNotSupported () const
 

Additional Inherited Members

- Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
 
virtual void drop (cOwnedObject *obj)
 
void dropAndDelete (cOwnedObject *obj)
 

Constructor & Destructor Documentation

◆ cExpression() [1/2]

cExpression ( )
inlineexplicit

Constructor.

◆ cExpression() [2/2]

cExpression ( const cExpression other)
inline

Copy constructor.

◆ ~cExpression()

virtual ~cExpression ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ operator=()

cExpression& operator= ( const cExpression other)
inline

Assignment operator.

◆ dup()

virtual cExpression* dup ( ) const
inlineoverridevirtual

Duplication not supported, this method is redefined to throw an error.

Reimplemented from cObject.

Reimplemented in cDynamicExpression.

◆ str()

virtual std::string str ( ) const
inlineoverridevirtual

Converts the expression to string.

Reimplemented from cObject.

Reimplemented in cDynamicExpression.

◆ parsimPack()

virtual void parsimPack ( cCommBuffer buffer) const
inlineoverridevirtual

Redefined to "de-inherit" it.

Reimplemented from cObject.

◆ parsimUnpack()

virtual void parsimUnpack ( cCommBuffer buffer)
inlineoverridevirtual

Redefined to "de-inherit" it.

Reimplemented from cObject.

◆ evaluate() [1/2]

virtual cNedValue evaluate ( Context context) const
pure virtual

Evaluate the expression and return the result in a cNedValue. The context parameter cannot be nullptr.

Implemented in cDynamicExpression.

Referenced by cDynamicExpression::dup().

◆ boolValue() [1/2]

virtual bool boolValue ( Context context) const
pure virtual

Evaluate the expression and convert the result to bool if possible; throw an error if conversion from that type is not supported.

Implemented in cDynamicExpression.

Referenced by cDynamicExpression::dup().

◆ intValue() [1/2]

virtual intpar_t intValue ( Context context,
const char *  expectedUnit = nullptr 
) const
pure virtual

Evaluate the expression and convert the result to intpar_t if possible; throw an error if conversion from that type is not supported. Also throws an error if the actual unit does not match the expected unit.

Implemented in cDynamicExpression.

Referenced by cDynamicExpression::dup().

◆ doubleValue() [1/2]

virtual double doubleValue ( Context context,
const char *  expectedUnit = nullptr 
) const
pure virtual

Evaluate the expression and convert the result to double if possible; throw an error if conversion from that type is not supported. Also throws an error if the actual unit does not match the expected unit.

Implemented in cDynamicExpression.

Referenced by cDynamicExpression::dup().

◆ stringValue() [1/2]

virtual std::string stringValue ( Context context) const
pure virtual

Evaluate the expression and convert the result to string if possible; throw an error if conversion from that type is not supported.

Implemented in cDynamicExpression.

Referenced by cDynamicExpression::dup().

◆ xmlValue() [1/2]

virtual cXMLElement* xmlValue ( Context context) const
pure virtual

Evaluate the expression and convert the result to an XML tree if possible; throw an error if conversion from that type is not supported.

Implemented in cDynamicExpression.

Referenced by cDynamicExpression::dup().

◆ evaluate() [2/2]

virtual cNedValue evaluate ( cComponent contextComponent = nullptr) const
virtual

Evaluate the expression and return the result in a cNedValue. This method creates a Context from contextComponent, and delegates to evaluate(Context*).

◆ boolValue() [2/2]

virtual bool boolValue ( cComponent contextComponent = nullptr) const
virtual

Evaluate the expression and convert the result to bool if possible; throw an error if conversion from that type is not supported. This method creates a Context from contextComponent, and delegates to boolValue(Context*).

◆ intValue() [2/2]

virtual intpar_t intValue ( cComponent contextComponent = nullptr,
const char *  expectedUnit = nullptr 
) const
virtual

Evaluate the expression and convert the result to intpar_t if possible; throw an error if conversion from that type is not supported. Also throws an error if the actual unit does not match the expected unit. This method creates a Context from contextComponent, and delegates to intValue(Context*,const char*).

◆ doubleValue() [2/2]

virtual double doubleValue ( cComponent contextComponent = nullptr,
const char *  expectedUnit = nullptr 
) const
virtual

Evaluate the expression and convert the result to double if possible; throw an error if conversion from that type is not supported. Also throws an error if the actual unit does not match the expected unit. This method creates a Context from contextComponent, and delegates to doubleValue(Context*,const char*).

◆ stringValue() [2/2]

virtual std::string stringValue ( cComponent contextComponent = nullptr) const
virtual

Evaluate the expression and convert the result to string if possible; throw an error if conversion from that type is not supported. This method creates a Context from contextComponent, and delegates to stringValue(Context*).

◆ xmlValue() [2/2]

virtual cXMLElement* xmlValue ( cComponent contextComponent = nullptr) const
virtual

Evaluate the expression and convert the result to an XML tree if possible; throw an error if conversion from that type is not supported. This method creates a Context from contextComponent, and delegates to xmlValue(Context*).

◆ parse()

virtual void parse ( const char *  text)
pure virtual

Interprets the string as an expression, and store it. If the text cannot be parsed, an exception is thrown, which can be caught as std::runtime_error& if necessary. An exception is also thrown if the particular cExpression subclass does not support parsing.

Implemented in cDynamicExpression.

◆ compare()

virtual int compare ( const cExpression other) const
pure virtual

Compares two expressions. Makes it possible to use cExpression as (part of) a key in std::map or std::set.

Implemented in cDynamicExpression.

◆ containsConstSubexpressions()

virtual bool containsConstSubexpressions ( ) const
pure virtual

Returns true if this expression contains const subexpressions.

Implemented in cDynamicExpression.

◆ evaluateConstSubexpressions()

virtual void evaluateConstSubexpressions ( Context context)
pure virtual

Evaluates const subexpressions, and replaces them with their values. See cDynamicExpression::Elem::CONSTSUBEXPR.

Implemented in cDynamicExpression.


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