16 #ifndef __OMNETPP_NEDSUPPORT_H 17 #define __OMNETPP_NEDSUPPORT_H 19 #include "cdynamicexpression.h" 23 namespace nedsupport {
25 class NedExpressionContext :
public cExpression::Context
28 enum ExpressionRole { SUBMODULE_CONDITION, SUBMODULE_ARRAY_CONDITION, OTHER };
29 explicit NedExpressionContext(cComponent *component, ExpressionRole role,
const char *computedTypename) :
30 cExpression::Context(component), role(role), computedTypename(computedTypename) {}
32 const char *computedTypename;
35 class ModuleIndex :
public cDynamicExpression::Functor
39 ModuleIndex *dup()
const override {
return new ModuleIndex();}
40 virtual const char *getFullName()
const override {
return "index";}
41 virtual const char *getArgTypes()
const override {
return "";}
42 virtual char getReturnType()
const override {
return 'L';}
43 virtual cNedValue evaluate(Context *context, cNedValue args[],
int numargs)
override;
44 virtual std::string str(std::string args[],
int numargs)
override;
47 class Exists :
public cDynamicExpression::Functor
52 Exists(
const char *ident,
bool ofParent);
53 Exists *dup()
const override {
return new Exists(ident.c_str(), ofParent);}
54 virtual const char *getFullName()
const override {
return "exists";}
55 virtual const char *getArgTypes()
const override {
return "";}
56 virtual char getReturnType()
const override {
return 'B';}
57 virtual cNedValue evaluate(Context *context, cNedValue args[],
int numargs)
override;
58 virtual std::string str(std::string args[],
int numargs)
override;
61 class Typename :
public cDynamicExpression::Functor
65 Typename *dup()
const override {
return new Typename();}
66 virtual const char *getFullName()
const override {
return "typename";}
67 virtual const char *getArgTypes()
const override {
return "";}
68 virtual char getReturnType()
const override {
return 'S';}
69 virtual cNedValue evaluate(Context *context, cNedValue args[],
int numargs)
override;
70 virtual std::string str(std::string args[],
int numargs)
override;
81 std::string paramName;
83 ParameterRef(
const char *paramName,
bool ofParent,
bool explicitKeyword);
85 virtual const char *
getFullName()
const override {
return paramName.c_str();}
86 virtual const char *getArgTypes()
const override {
return "";}
87 virtual char getReturnType()
const override {
return '*';}
89 virtual std::string str(std::string args[],
int numargs)
override;
99 std::string moduleName;
100 bool withModuleIndex;
101 std::string paramName;
105 virtual const char *
getFullName()
const override {
return paramName.c_str();}
106 virtual const char *getArgTypes()
const override {
return withModuleIndex ?
"L" :
"";}
107 virtual char getReturnType()
const override {
return '*';}
109 virtual std::string str(std::string args[],
int numargs)
override;
119 static const char *varNames[32];
120 static long vars[32];
123 static long& pushVar(
const char *varName);
124 static void popVar();
126 static const char **getVarNames() {
return varNames;}
127 static int getNumVars() {
return varCount;}
132 LoopVar(
const char *varName) {this->varName = varName;}
134 virtual const char *
getFullName()
const override {
return varName.c_str();}
135 virtual const char *getArgTypes()
const override {
return "";}
136 virtual char getReturnType()
const override {
return 'L';}
138 virtual std::string str(std::string args[],
int numargs)
override;
149 bool explicitKeyword;
152 Sizeof(
const char *ident,
bool ofParent,
bool explicitKeyword);
153 Sizeof *
dup()
const override {
return new Sizeof(ident.c_str(), ofParent, explicitKeyword);}
154 virtual const char *
getFullName()
const override {
return ident.c_str();}
155 virtual const char *getArgTypes()
const override {
return "";}
156 virtual char getReturnType()
const override {
return 'L';}
158 virtual std::string str(std::string args[],
int numargs)
override;
ParameterRef * dup() const override
Definition: nedsupport.h:84
virtual const char * getFullName() const override
Definition: nedsupport.h:105
i,j in NED "for" loops
Definition: nedsupport.h:115
virtual const char * getFullName() const override
Definition: nedsupport.h:134
Function object base class. We use function objects to handle NED parameter references, "index" and "sizeof" operators, and references to NED "for" loop variables.
Definition: cdynamicexpression.h:237
sizeof operator. See also: SiblingModuleSizeof
Definition: nedsupport.h:145
siblingModuleParameter, indexedSiblingModuleParameter
Definition: nedsupport.h:95
Value used during evaluating NED expressions.
Definition: cnedvalue.h:50
virtual const char * getFullName() const override
Definition: nedsupport.h:154
Variations: parameter, parentParameter.
Definition: nedsupport.h:76
LoopVar * dup() const override
Definition: nedsupport.h:133
Sizeof * dup() const override
Definition: nedsupport.h:153
Definition: cabstracthistogram.h:21
virtual const char * getFullName() const override
Definition: nedsupport.h:85
SiblingModuleParameterRef * dup() const override
Definition: nedsupport.h:104
Contextual information for evaluating the expression.
Definition: cexpression.h:39