|
OMNeT++ API 6.1
Discrete Event Simulation Library
|
|
16 #ifndef __OMNETPP_CDYNAMICEXPRESSION_H
17 #define __OMNETPP_CDYNAMICEXPRESSION_H
21 #include "cexpression.h"
22 #include "cownedobject.h"
27 namespace common {
class Expression; }
31 class cNedMathFunction;
78 typedef IResolver ResolverBase;
85 std::map<std::string, cValue> variables;
86 std::map<std::string, std::vector<cValue>> arrays;
89 SymbolTable(
const std::map<std::string, cValue>& variables) : variables(variables) {}
90 SymbolTable(
const std::map<std::string, cValue>& variables,
const std::map<std::string, std::vector<cValue>>& arrays) : variables(variables), arrays(arrays) {}
92 virtual cValue readVariable(
Context *context,
const char *name)
override;
97 common::Expression *expression =
nullptr;
98 IResolver *resolver =
nullptr;
137 virtual std::string str()
const override;
145 virtual void parse(
const char *text)
override;
162 virtual void parse(
const char *text,
const std::map<std::string,cValue>& symbolTable) {
parse(text); setResolver(
new SymbolTable(symbolTable));}
167 virtual void setResolver(IResolver *resolver);
177 virtual void parseNedExpr(
const char *text);
183 virtual cValue evaluate(Context *context)
const override;
189 virtual bool boolValue(Context *context)
const override;
196 virtual intval_t intValue(Context *context,
const char *expectedUnit=
nullptr)
const override;
202 virtual double doubleValue(Context *context,
const char *expectedUnit=
nullptr)
const override;
208 virtual std::string stringValue(Context *context)
const override;
214 virtual cXMLElement *xmlValue(Context *context)
const override;
229 virtual int compare(
const cExpression *other)
const override;
235 virtual bool isAConstant()
const override;
253 static double convertUnit(
double d,
const char *unit,
const char *targetUnit);
virtual std::string stringValue(Context *context) const =0
An "owned" version cDynamicExpression to allow it to be assigned to module parameters of the type "ob...
Definition: cdynamicexpression.h:263
virtual std::string str() const override
Definition: cdynamicexpression.h:304
cOwnedDynamicExpression & operator=(const cOwnedDynamicExpression &other)=default
A variant-like value class used during evaluating NED expressions.
Definition: cvalue.h:47
virtual cDynamicExpression * dup() const override
Definition: cdynamicexpression.h:131
Abstract base class for expression evaluators.
Definition: cexpression.h:33
virtual intval_t intValue(Context *context, const char *expectedUnit=nullptr) const =0
cOwnedDynamicExpression(const char *name=nullptr)
Definition: cdynamicexpression.h:276
virtual bool boolValue(Context *context) const =0
virtual cValue readVariable(Context *context, const char *name, intval_t index)
Definition: cdynamicexpression.h:62
virtual cValue readMember(Context *context, const cValue &object, const char *name, intval_t index)
Definition: cdynamicexpression.h:68
A stack-based expression evaluator class, for dynamically created expressions.
Definition: cdynamicexpression.h:40
cDynamicExpression(const cDynamicExpression &other)
Definition: cdynamicexpression.h:116
virtual cValue readMember(Context *context, const cValue &object, const char *name)
Definition: cdynamicexpression.h:65
virtual cValue callFunction(Context *context, const char *name, cValue argv[], int argc)
Definition: cdynamicexpression.h:71
virtual double doubleValue(Context *context, const char *expectedUnit=nullptr) const =0
Definition: fileline.h:27
Contextual information for evaluating the expression.
Definition: cexpression.h:39
virtual std::string getSourceLocation() const override
Definition: cdynamicexpression.h:247
cOwnedDynamicExpression(const cOwnedDynamicExpression &other)
Definition: cdynamicexpression.h:281
Definition: cdynamicexpression.h:48
virtual cValue callMethod(Context *context, const cValue &object, const char *name, cValue argv[], int argc)
Definition: cdynamicexpression.h:74
virtual cValue readVariable(Context *context, const char *name)
Definition: cdynamicexpression.h:59
virtual cXMLElement * xmlValue(Context *context) const =0
int64_t intval_t
Signed integer type which is guaranteed to be at least 64 bits wide. It is used throughout the librar...
Definition: simkerneldefs.h:101
virtual void parse(const char *text, const std::map< std::string, cValue > &symbolTable)
Definition: cdynamicexpression.h:162
Definition: cdynamicexpression.h:83
void setSourceLocation(FileLine loc)
Definition: cdynamicexpression.h:241
Represents an XML element in an XML configuration file.
Definition: cxmlelement.h:75
virtual SymbolTable * dup() const override
Definition: cdynamicexpression.h:91
virtual cOwnedDynamicExpression * dup() const override
Definition: cdynamicexpression.h:298
virtual IResolver * getResolver() const
Definition: cdynamicexpression.h:172
Thrown when the simulation kernel or other components detect a runtime error.
Definition: cexception.h:286
virtual cValue evaluate(Context *context) const =0
virtual void parse(const char *text, IResolver *resolver)
Definition: cdynamicexpression.h:153
Buffer for the communications layer of parallel simulation.
Definition: ccommbuffer.h:41
virtual std::string str() const override
A cObject that keeps track of its owner. It serves as base class for many classes in the OMNeT++ libr...
Definition: cownedobject.h:105