QuISP
Loading...
Searching...
No Matches
StaticEnv.h
Go to the documentation of this file.
1#pragma once
2
3#include <omnetpp.h>
4#include "Configuration.h"
5#include "omnetpp/cconfiguration.h"
6
7namespace quisp_test::env {
8
9using namespace omnetpp;
10
15class StaticEnv : public omnetpp::cEnvir {
16 protected:
17 void unsupported() const { throw std::runtime_error("StaticEnv: Unsupported method called"); }
18 void alert(const char *msg) override { ::printf("\n<!> %s\n\n", msg); }
19 bool askYesNo(const char *msg) override {
21 return false;
22 }
23
24 public:
25 StaticEnv();
27
28 // eventlog callback interface
29 void objectDeleted(cObject *object) override {}
30 void simulationEvent(cEvent *event) override {}
31 void messageScheduled(cMessage *msg) override {}
32 void messageCancelled(cMessage *msg) override {}
33 void beginSend(cMessage *msg, const omnetpp::SendOptions &options) override {}
34 void messageSendDirect(cMessage *msg, cGate *toGate, const omnetpp::ChannelResult &result) override {}
35 void messageSendHop(cMessage *msg, cGate *srcGate) override {}
36 void messageSendHop(cMessage *msg, cGate *srcGate, const omnetpp::ChannelResult &result) override {}
37 void endSend(cMessage *msg) override {}
38 void messageCreated(cMessage *msg) override {}
39 void messageCloned(cMessage *msg, cMessage *clone) override {}
40 void messageDeleted(cMessage *msg) override {}
41 void moduleReparented(cModule *module, cModule *oldparent, int oldId) override {}
42 void componentMethodBegin(cComponent *from, cComponent *to, const char *methodFmt, va_list va, bool silent) override {}
43 void componentMethodEnd() override {}
44 void moduleCreated(cModule *newmodule) override {}
45 void moduleDeleted(cModule *module) override {}
46 void gateCreated(cGate *newgate) override {}
47 void gateDeleted(cGate *gate) override {}
48 void connectionCreated(cGate *srcgate) override {}
49 void connectionDeleted(cGate *srcgate) override {}
50 void displayStringChanged(cComponent *component) override {}
51 void undisposedObject(cObject *obj) override;
52 void log(cLogEntry *entry) override {}
53
54 // configuration, model parameters
55 void preconfigure(cComponent *component) override {}
56 void configure(cComponent *component) override {}
57 void readParameter(cPar *parameter) override { unsupported(); }
58 bool isModuleLocal(cModule *parentmod, const char *modname, int index) override { return true; }
59 cXMLElement *getXMLDocument(const char *filename, const char *xpath = nullptr) override {
61 return nullptr;
62 }
63 cXMLElement *getParsedXMLString(const char *content, const char *xpath = nullptr) override {
65 return nullptr;
66 }
67 void forgetXMLDocument(const char *filename) override {}
68 void forgetParsedXMLString(const char *content) override {}
69 void flushXMLDocumentCache() override {}
70 void flushXMLParsedContentCache() override {}
71 unsigned getExtraStackForEnvir() const override { return 0; }
72 cConfiguration *getConfig() override;
73 std::string resolveResourcePath(const char *fileName, cComponentType *context) override { return ""; }
74 bool isGUI() const override { return false; }
75 bool isExpressMode() const override { return false; }
76
77 // UI functions (see also protected ones)
78 void bubble(cComponent *component, const char *text) override {}
79 std::string gets(const char *prompt, const char *defaultreply = nullptr) override;
80 cEnvir &flush() {
81 ::fflush(stdout);
82 return *this;
83 }
84
85 // RNGs
86 int getNumRNGs() const override { return 0; }
87 cRNG *getRNG(int k) override;
88
89 // output vectors
90 void *registerOutputVector(const char *modulename, const char *vectorname) override { return nullptr; }
91 void deregisterOutputVector(void *vechandle) override {}
92 void setVectorAttribute(void *vechandle, const char *name, const char *value) override {}
93 bool recordInOutputVector(void *vechandle, simtime_t t, double value) override { return false; }
94
95 // output scalars
96 void recordScalar(cComponent *component, const char *name, double value, opp_string_map *attributes = nullptr) override {}
97 void recordStatistic(cComponent *component, const char *name, cStatistic *statistic, opp_string_map *attributes = nullptr) override {}
98
99 void addResultRecorders(cComponent *component, simsignal_t signal, const char *statisticName, cProperty *statisticTemplateProperty) override {}
100
101 // snapshot file
102 virtual std::ostream *getStreamForSnapshot() override {
103 unsupported();
104 return nullptr;
105 }
106 void releaseStreamForSnapshot(std::ostream *os) override { unsupported(); }
107
108 // misc
109 int getArgCount() const override {
110 unsupported();
111 return 0;
112 }
113 char **getArgVector() const override {
114 unsupported();
115 return nullptr;
116 }
117 int getParsimProcId() const override { return 0; }
118 int getParsimNumPartitions() const override { return 1; }
119 unsigned long getUniqueNumber() override {
120 unsupported();
121 return 0;
122 }
123 bool idle() override { return false; }
124 void refOsgNode(osg::Node *scene) override {}
125 void unrefOsgNode(osg::Node *scene) override {}
126 bool ensureDebugger(cRuntimeError *) override { return false; }
127
128 void getImageSize(const char *imageName, double &outWidth, double &outHeight) override { unsupported(); }
129 void getTextExtent(const cFigure::Font &font, const char *text, double &outWidth, double &outHeight, double &outAscent) override { unsupported(); }
130 void appendToImagePath(const char *directory) override { unsupported(); }
131 void loadImage(const char *fileName, const char *imageName = nullptr) override { unsupported(); }
132 cFigure::Rectangle getSubmoduleBounds(const cModule *submodule) override { return cFigure::Rectangle(NAN, NAN, NAN, NAN); }
133 double getZoomLevel(const cModule *module) override { return NAN; }
134 double getAnimationTime() const override { return 0; }
135 double getAnimationSpeed() const override { return 0; }
136 double getRemainingAnimationHoldTime() const override { return 0; }
137
138 // lifecycle listeners
139 void addLifecycleListener(cISimulationLifecycleListener *listener) override {}
140 void removeLifecycleListener(cISimulationLifecycleListener *listener) override {}
141 void notifyLifecycleListeners(SimulationLifecycleEventType eventType, cObject *details) override {}
142
143 std::vector<cFigure::Point> getConnectionLine(const cGate *sourceGate) override { return std::vector<cFigure::Point>(); }
144 void recordParameter(cPar *par) override {}
145 void recordComponentType(cComponent *component) override {}
146 void pausePoint() override {}
147
148 cSimulation *newSimulation();
149 void resetSimulation();
150 cRNG *rng = nullptr;
151 cConfiguration *config = nullptr;
152};
153
154} // namespace quisp_test::env
cEnvir implementation for unit testing based on OMNeT++'s StaticEnv.
Definition StaticEnv.h:15
void beginSend(cMessage *msg, const omnetpp::SendOptions &options) override
Definition StaticEnv.h:33
char ** getArgVector() const override
Definition StaticEnv.h:113
void gateCreated(cGate *newgate) override
Definition StaticEnv.h:46
int getNumRNGs() const override
Definition StaticEnv.h:86
void alert(const char *msg) override
Definition StaticEnv.h:18
void refOsgNode(osg::Node *scene) override
Definition StaticEnv.h:124
void componentMethodEnd() override
Definition StaticEnv.h:43
void componentMethodBegin(cComponent *from, cComponent *to, const char *methodFmt, va_list va, bool silent) override
Definition StaticEnv.h:42
void displayStringChanged(cComponent *component) override
Definition StaticEnv.h:50
void readParameter(cPar *parameter) override
Definition StaticEnv.h:57
void resetSimulation()
delete all cObjects in cSimulation::defaultList.
Definition StaticEnv.cc:44
void gateDeleted(cGate *gate) override
Definition StaticEnv.h:47
void log(cLogEntry *entry) override
Definition StaticEnv.h:52
cSimulation * newSimulation()
delete current simulation and then setup new simulation
Definition StaticEnv.cc:29
cFigure::Rectangle getSubmoduleBounds(const cModule *submodule) override
Definition StaticEnv.h:132
void simulationEvent(cEvent *event) override
Definition StaticEnv.h:30
virtual std::ostream * getStreamForSnapshot() override
Definition StaticEnv.h:102
void bubble(cComponent *component, const char *text) override
Definition StaticEnv.h:78
void configure(cComponent *component) override
Definition StaticEnv.h:56
void recordScalar(cComponent *component, const char *name, double value, opp_string_map *attributes=nullptr) override
Definition StaticEnv.h:96
int getArgCount() const override
Definition StaticEnv.h:109
unsigned long getUniqueNumber() override
Definition StaticEnv.h:119
bool ensureDebugger(cRuntimeError *) override
Definition StaticEnv.h:126
cXMLElement * getParsedXMLString(const char *content, const char *xpath=nullptr) override
Definition StaticEnv.h:63
cConfiguration * getConfig() override
Definition StaticEnv.cc:12
void forgetParsedXMLString(const char *content) override
Definition StaticEnv.h:68
std::string gets(const char *prompt, const char *defaultreply=nullptr) override
Definition StaticEnv.cc:13
bool idle() override
Definition StaticEnv.h:123
void getTextExtent(const cFigure::Font &font, const char *text, double &outWidth, double &outHeight, double &outAscent) override
Definition StaticEnv.h:129
std::string resolveResourcePath(const char *fileName, cComponentType *context) override
Definition StaticEnv.h:73
void * registerOutputVector(const char *modulename, const char *vectorname) override
Definition StaticEnv.h:90
void flushXMLParsedContentCache() override
Definition StaticEnv.h:70
bool isModuleLocal(cModule *parentmod, const char *modname, int index) override
Definition StaticEnv.h:58
void objectDeleted(cObject *object) override
Definition StaticEnv.h:29
void messageScheduled(cMessage *msg) override
Definition StaticEnv.h:31
void messageDeleted(cMessage *msg) override
Definition StaticEnv.h:40
void unrefOsgNode(osg::Node *scene) override
Definition StaticEnv.h:125
void undisposedObject(cObject *obj) override
Definition StaticEnv.cc:17
cXMLElement * getXMLDocument(const char *filename, const char *xpath=nullptr) override
Definition StaticEnv.h:59
std::vector< cFigure::Point > getConnectionLine(const cGate *sourceGate) override
Definition StaticEnv.h:143
cEnvir & flush()
Definition StaticEnv.h:80
void setVectorAttribute(void *vechandle, const char *name, const char *value) override
Definition StaticEnv.h:92
void removeLifecycleListener(cISimulationLifecycleListener *listener) override
Definition StaticEnv.h:140
void addResultRecorders(cComponent *component, simsignal_t signal, const char *statisticName, cProperty *statisticTemplateProperty) override
Definition StaticEnv.h:99
void forgetXMLDocument(const char *filename) override
Definition StaticEnv.h:67
void appendToImagePath(const char *directory) override
Definition StaticEnv.h:130
void notifyLifecycleListeners(SimulationLifecycleEventType eventType, cObject *details) override
Definition StaticEnv.h:141
int getParsimProcId() const override
Definition StaticEnv.h:117
void deregisterOutputVector(void *vechandle) override
Definition StaticEnv.h:91
void messageSendHop(cMessage *msg, cGate *srcGate, const omnetpp::ChannelResult &result) override
Definition StaticEnv.h:36
void releaseStreamForSnapshot(std::ostream *os) override
Definition StaticEnv.h:106
double getAnimationSpeed() const override
Definition StaticEnv.h:135
void messageCancelled(cMessage *msg) override
Definition StaticEnv.h:32
~StaticEnv()
Definition StaticEnv.h:26
void addLifecycleListener(cISimulationLifecycleListener *listener) override
Definition StaticEnv.h:139
void getImageSize(const char *imageName, double &outWidth, double &outHeight) override
Definition StaticEnv.h:128
void recordComponentType(cComponent *component) override
Definition StaticEnv.h:145
bool askYesNo(const char *msg) override
Definition StaticEnv.h:19
double getRemainingAnimationHoldTime() const override
Definition StaticEnv.h:136
void flushXMLDocumentCache() override
Definition StaticEnv.h:69
void connectionDeleted(cGate *srcgate) override
Definition StaticEnv.h:49
void messageCreated(cMessage *msg) override
Definition StaticEnv.h:38
void messageCloned(cMessage *msg, cMessage *clone) override
Definition StaticEnv.h:39
void moduleDeleted(cModule *module) override
Definition StaticEnv.h:45
void loadImage(const char *fileName, const char *imageName=nullptr) override
Definition StaticEnv.h:131
void moduleReparented(cModule *module, cModule *oldparent, int oldId) override
Definition StaticEnv.h:41
cRNG * rng
Definition StaticEnv.h:150
bool isExpressMode() const override
Definition StaticEnv.h:75
void pausePoint() override
Definition StaticEnv.h:146
void moduleCreated(cModule *newmodule) override
Definition StaticEnv.h:44
StaticEnv()
Definition StaticEnv.cc:10
unsigned getExtraStackForEnvir() const override
Definition StaticEnv.h:71
void preconfigure(cComponent *component) override
Definition StaticEnv.h:55
cConfiguration * config
Definition StaticEnv.h:151
bool recordInOutputVector(void *vechandle, simtime_t t, double value) override
Definition StaticEnv.h:93
double getZoomLevel(const cModule *module) override
Definition StaticEnv.h:133
void recordParameter(cPar *par) override
Definition StaticEnv.h:144
int getParsimNumPartitions() const override
Definition StaticEnv.h:118
cRNG * getRNG(int k) override
Definition StaticEnv.cc:19
void unsupported() const
Definition StaticEnv.h:17
bool isGUI() const override
Definition StaticEnv.h:74
void recordStatistic(cComponent *component, const char *name, cStatistic *statistic, opp_string_map *attributes=nullptr) override
Definition StaticEnv.h:97
void messageSendHop(cMessage *msg, cGate *srcGate) override
Definition StaticEnv.h:35
void connectionCreated(cGate *srcgate) override
Definition StaticEnv.h:48
void endSend(cMessage *msg) override
Definition StaticEnv.h:37
void messageSendDirect(cMessage *msg, cGate *toGate, const omnetpp::ChannelResult &result) override
Definition StaticEnv.h:34
double getAnimationTime() const override
Definition StaticEnv.h:134
Definition StaticEnv.cc:7