OMNeT++ Simulation Library  5.6.1
cnullenvir.h
1 //==========================================================================
2 // CNULLENVIR.H - part of
3 // OMNeT++/OMNEST
4 // Discrete System Simulation in C++
5 //
6 //==========================================================================
7 
8 /*--------------------------------------------------------------*
9  Copyright (C) 1992-2017 Andras Varga
10  Copyright (C) 2006-2017 OpenSim Ltd.
11 
12  This file is distributed WITHOUT ANY WARRANTY. See the file
13  `license' for details on this and other legal matters.
14 *--------------------------------------------------------------*/
15 
16 #ifndef __OMNETPP_CNULLENVIR_H
17 #define __OMNETPP_CNULLENVIR_H
18 
19 #include "cenvir.h"
20 #include "cexception.h"
21 #include "ccomponent.h"
22 #include "cmersennetwister.h"
23 
24 namespace omnetpp {
25 
26 
49 class SIM_API cNullEnvir : public cEnvir
50 {
51  protected:
52  int argc;
53  char **argv;
54  cConfiguration *cfg;
55  cRNG *rng;
56  unsigned long nextUniqueNumber;
57  std::vector<cISimulationLifecycleListener*> listeners;
58 
59  protected:
60  void unsupported() const {throw cRuntimeError("cNullEnvir: Unsupported method called");}
61  virtual void alert(const char *msg) override {::printf("\n<!> %s\n\n", msg);}
62  virtual bool askYesNo(const char *prompt) override {unsupported(); return false;}
63 
64  public:
65  // constructor, destructor
66  cNullEnvir(int ac, char **av, cConfiguration *c);
67  virtual ~cNullEnvir();
68 
69  // eventlog callback interface
70  virtual void objectDeleted(cObject *object) override {}
71  virtual void simulationEvent(cEvent *event) override {}
72  virtual void messageScheduled(cMessage *msg) override {}
73  virtual void messageCancelled(cMessage *msg) override {}
74  virtual void beginSend(cMessage *msg) override {}
75  virtual void messageSendDirect(cMessage *msg, cGate *toGate, simtime_t propagationDelay, simtime_t transmissionDelay) override {}
76  virtual void messageSendHop(cMessage *msg, cGate *srcGate) override {}
77  virtual void messageSendHop(cMessage *msg, cGate *srcGate, simtime_t propagationDelay, simtime_t transmissionDelay, bool discard) override {}
78  virtual void endSend(cMessage *msg) override {}
79  virtual void messageCreated(cMessage *msg) override {}
80  virtual void messageCloned(cMessage *msg, cMessage *clone) override {}
81  virtual void messageDeleted(cMessage *msg) override {}
82  virtual void moduleReparented(cModule *module, cModule *oldparent, int oldId) override {}
83  virtual void componentMethodBegin(cComponent *from, cComponent *to, const char *methodFmt, va_list va, bool silent) override {}
84  virtual void componentMethodEnd() override {}
85  virtual void moduleCreated(cModule *newmodule) override {}
86  virtual void moduleDeleted(cModule *module) override {}
87  virtual void gateCreated(cGate *newgate) override {}
88  virtual void gateDeleted(cGate *gate) override {}
89  virtual void connectionCreated(cGate *srcgate) override {}
90  virtual void connectionDeleted(cGate *srcgate) override {}
91  virtual void displayStringChanged(cComponent *component) override {}
92  virtual void undisposedObject(cObject *obj) override {}
93  virtual void log(cLogEntry *entry) override {}
94 
95  // configuration, model parameters
96  virtual void preconfigure(cComponent *component) override {}
97  virtual void configure(cComponent *component) override {}
98  virtual void readParameter(cPar *par) override {unsupported();}
99  virtual bool isModuleLocal(cModule *parentmod, const char *modname, int index) override {return true;}
100  virtual cXMLElement *getXMLDocument(const char *filename, const char *xpath=nullptr) override {unsupported(); return nullptr;}
101  virtual cXMLElement *getParsedXMLString(const char *content, const char *xpath=nullptr) override {unsupported(); return nullptr;}
102  virtual void forgetXMLDocument(const char *filename) override {}
103  virtual void forgetParsedXMLString(const char *content) override {}
104  virtual void flushXMLDocumentCache() override {}
105  virtual void flushXMLParsedContentCache() override {}
106  virtual unsigned getExtraStackForEnvir() const override {return 0;}
107  virtual cConfiguration *getConfig() override {return cfg;}
108  virtual std::string resolveResourcePath(const char *fileName, cComponentType *context) override {return fileName;}
109  virtual bool isGUI() const override {return false;}
110  virtual bool isExpressMode() const override {return false;}
111 
112  virtual void getImageSize(const char *imageName, double& outWidth, double& outHeight) override {unsupported();}
113  virtual void getTextExtent(const cFigure::Font& font, const char *text, double& outWidth, double& outHeight, double& outAscent) override {unsupported();}
114  virtual void appendToImagePath(const char *directory) override {unsupported();}
115  virtual void loadImage(const char *fileName, const char *imageName=nullptr) override {unsupported();}
116  virtual cFigure::Rectangle getSubmoduleBounds(const cModule *submodule) override {return cFigure::Rectangle(NAN, NAN, NAN, NAN);}
117  virtual double getZoomLevel(const cModule *module) override {return NAN;}
118  virtual double getAnimationTime() const override {return 0;}
119  virtual double getAnimationSpeed() const override {return 0;}
120  virtual double getRemainingAnimationHoldTime() const override {return 0;}
121 
122  // UI functions (see also protected ones)
123  virtual void bubble(cComponent *component, const char *text) override {}
124  virtual std::string gets(const char *prompt, const char *defaultreply=nullptr) override {unsupported(); return "";}
125  virtual cEnvir& flush() {::fflush(stdout); return *this;}
126 
127  // RNGs
128  virtual int getNumRNGs() const override {return 1;}
129  virtual cRNG *getRNG(int k) override {return rng;}
130 
131  // output vectors
132  virtual void *registerOutputVector(const char *modulename, const char *vectorname) override {return (void *)1;}
133  virtual void deregisterOutputVector(void *vechandle) override {}
134  virtual void setVectorAttribute(void *vechandle, const char *name, const char *value) override {}
135  virtual bool recordInOutputVector(void *vechandle, simtime_t t, double value) override {return false;}
136 
137  // output scalars
138  virtual void recordScalar(cComponent *component, const char *name, double value, opp_string_map *attributes=nullptr) override {}
139  virtual void recordStatistic(cComponent *component, const char *name, cStatistic *statistic, opp_string_map *attributes=nullptr) override {}
140 
141  virtual void addResultRecorders(cComponent *component, simsignal_t signal, const char *statisticName, cProperty *statisticTemplateProperty) override {}
142 
143  // snapshot file
144  virtual std::ostream *getStreamForSnapshot() override {unsupported(); return nullptr;}
145  virtual void releaseStreamForSnapshot(std::ostream *os) override {unsupported();}
146 
147  // misc
148  virtual int getArgCount() const override {return argc;}
149  virtual char **getArgVector() const override {return argv;}
150  virtual int getParsimProcId() const override {return 0;}
151  virtual int getParsimNumPartitions() const override {return 1;}
152  virtual unsigned long getUniqueNumber() override {return nextUniqueNumber++;}
153  virtual void refOsgNode(osg::Node *scene) override {}
154  virtual void unrefOsgNode(osg::Node *scene) override {}
155  virtual bool idle() override {return false;}
156  virtual bool ensureDebugger(cRuntimeError *) override { return false; }
157 
158  // lifecycle listeners
159  virtual void addLifecycleListener(cISimulationLifecycleListener *listener) override;
160  virtual void removeLifecycleListener(cISimulationLifecycleListener *listener) override;
161  virtual void notifyLifecycleListeners(SimulationLifecycleEventType eventType, cObject *details) override;
162 };
163 
164 
165 } // namespace omnetpp
166 
167 #endif
168 
169 
virtual double getRemainingAnimationHoldTime() const override
Definition: cnullenvir.h:120
virtual char ** getArgVector() const override
Definition: cnullenvir.h:149
The message class in OMNeT++. cMessage objects may represent events, messages, jobs or other entities...
Definition: cmessage.h:95
virtual void gateCreated(cGate *newgate) override
Definition: cnullenvir.h:87
Thrown when the simulation kernel or other components detect a runtime error.
Definition: cexception.h:283
Common base for module and channel classes.
Definition: ccomponent.h:48
virtual void bubble(cComponent *component, const char *text) override
Definition: cnullenvir.h:123
Represents a module gate.
Definition: cgate.h:63
virtual void forgetXMLDocument(const char *filename) override
Definition: cnullenvir.h:102
Root of the OMNeT++ class hierarchy. cObject is a lightweight class without any data members...
Definition: cobject.h:58
virtual void messageSendHop(cMessage *msg, cGate *srcGate) override
Definition: cnullenvir.h:76
virtual void beginSend(cMessage *msg) override
Definition: cnullenvir.h:74
int64_t-based, base-10 fixed-point simulation time.
Definition: simtime.h:66
virtual std::ostream * getStreamForSnapshot() override
Definition: cnullenvir.h:144
virtual void undisposedObject(cObject *obj) override
Definition: cnullenvir.h:92
virtual void loadImage(const char *fileName, const char *imageName=nullptr) override
Definition: cnullenvir.h:115
virtual void getImageSize(const char *imageName, double &outWidth, double &outHeight) override
Definition: cnullenvir.h:112
virtual std::string resolveResourcePath(const char *fileName, cComponentType *context) override
Definition: cnullenvir.h:108
virtual void addResultRecorders(cComponent *component, simsignal_t signal, const char *statisticName, cProperty *statisticTemplateProperty) override
Definition: cnullenvir.h:141
virtual double getAnimationTime() const override
Definition: cnullenvir.h:118
virtual std::string gets(const char *prompt, const char *defaultreply=nullptr) override
Definition: cnullenvir.h:124
virtual void moduleReparented(cModule *module, cModule *oldparent, int oldId) override
Definition: cnullenvir.h:82
virtual double getAnimationSpeed() const override
Definition: cnullenvir.h:119
Represents an XML element in an XML configuration file.
Definition: cxmlelement.h:73
virtual bool idle() override
Definition: cnullenvir.h:155
Abstract interface for random number generator classes.
Definition: crng.h:49
virtual cRNG * getRNG(int k) override
Definition: cnullenvir.h:129
Represents an event in the discrete event simulator.
Definition: cevent.h:43
virtual void preconfigure(cComponent *component) override
Definition: cnullenvir.h:96
Represents a module or channel parameter.
Definition: cpar.h:68
virtual void setVectorAttribute(void *vechandle, const char *name, const char *value) override
Definition: cnullenvir.h:134
virtual void endSend(cMessage *msg) override
Definition: cnullenvir.h:78
A callback interface for receiving notifications at various stages simulations, including setting up...
Definition: clifecyclelistener.h:186
virtual void readParameter(cPar *par) override
Definition: cnullenvir.h:98
virtual unsigned getExtraStackForEnvir() const override
Definition: cnullenvir.h:106
virtual bool askYesNo(const char *prompt) override
Definition: cnullenvir.h:62
virtual void componentMethodEnd() override
Definition: cnullenvir.h:84
virtual bool recordInOutputVector(void *vechandle, simtime_t t, double value) override
Definition: cnullenvir.h:135
virtual int getParsimProcId() const override
Definition: cnullenvir.h:150
virtual void * registerOutputVector(const char *modulename, const char *vectorname) override
Definition: cnullenvir.h:132
virtual cFigure::Rectangle getSubmoduleBounds(const cModule *submodule) override
Definition: cnullenvir.h:116
virtual void getTextExtent(const cFigure::Font &font, const char *text, double &outWidth, double &outHeight, double &outAscent) override
Definition: cnullenvir.h:113
virtual bool isModuleLocal(cModule *parentmod, const char *modname, int index) override
Definition: cnullenvir.h:99
cEnvir represents the "environment" or user interface of the simulation.
Definition: cenvir.h:73
virtual void releaseStreamForSnapshot(std::ostream *os) override
Definition: cnullenvir.h:145
virtual void messageDeleted(cMessage *msg) override
Definition: cnullenvir.h:81
virtual bool isGUI() const override
Definition: cnullenvir.h:109
virtual void moduleCreated(cModule *newmodule) override
Definition: cnullenvir.h:85
This class holds various data that is captured when a particular log statement executes. It also contains the text written to the log stream.
Definition: clog.h:369
virtual void recordStatistic(cComponent *component, const char *name, cStatistic *statistic, opp_string_map *attributes=nullptr) override
Definition: cnullenvir.h:139
virtual cConfiguration * getConfig() override
Definition: cnullenvir.h:107
virtual void log(cLogEntry *entry) override
Definition: cnullenvir.h:93
virtual int getParsimNumPartitions() const override
Definition: cnullenvir.h:151
This class represents modules in the simulation.
Definition: cmodule.h:47
virtual void refOsgNode(osg::Node *scene) override
Definition: cnullenvir.h:153
virtual void deregisterOutputVector(void *vechandle) override
Definition: cnullenvir.h:133
Stores a (NED) property with its (possibly compound) value.
Definition: cproperty.h:38
virtual void messageSendHop(cMessage *msg, cGate *srcGate, simtime_t propagationDelay, simtime_t transmissionDelay, bool discard) override
Definition: cnullenvir.h:77
A do-nothing cEnvir implementation.
Definition: cnullenvir.h:49
Lightweight string-to-string map, used internally in some parts of OMNeT++.
Definition: opp_string.h:200
virtual void forgetParsedXMLString(const char *content) override
Definition: cnullenvir.h:103
virtual void gateDeleted(cGate *gate) override
Definition: cnullenvir.h:88
virtual void messageCreated(cMessage *msg) override
Definition: cnullenvir.h:79
virtual int getArgCount() const override
Definition: cnullenvir.h:148
virtual int getNumRNGs() const override
Definition: cnullenvir.h:128
virtual void connectionDeleted(cGate *srcgate) override
Definition: cnullenvir.h:90
virtual void simulationEvent(cEvent *event) override
Definition: cnullenvir.h:71
virtual void messageCloned(cMessage *msg, cMessage *clone) override
Definition: cnullenvir.h:80
virtual cXMLElement * getParsedXMLString(const char *content, const char *xpath=nullptr) override
Definition: cnullenvir.h:101
virtual bool isExpressMode() const override
Definition: cnullenvir.h:110
virtual unsigned long getUniqueNumber() override
Definition: cnullenvir.h:152
Common base class for cModuleType and cChannelType.
Definition: ccomponenttype.h:49
Definition: cabstracthistogram.h:21
virtual void connectionCreated(cGate *srcgate) override
Definition: cnullenvir.h:89
virtual void alert(const char *msg) override
Definition: cnullenvir.h:61
virtual void appendToImagePath(const char *directory) override
Definition: cnullenvir.h:114
virtual void recordScalar(cComponent *component, const char *name, double value, opp_string_map *attributes=nullptr) override
Definition: cnullenvir.h:138
virtual void componentMethodBegin(cComponent *from, cComponent *to, const char *methodFmt, va_list va, bool silent) override
Definition: cnullenvir.h:83
Represents a rectangle as an (x,y,width,height) tuple.
Definition: ccanvas.h:90
virtual void messageScheduled(cMessage *msg) override
Definition: cnullenvir.h:72
virtual void configure(cComponent *component) override
Definition: cnullenvir.h:97
SimulationLifecycleEventType
Event type for cISimulationLifecycleListener&#39;s lifecycleEvent() method.
Definition: clifecyclelistener.h:28
virtual bool ensureDebugger(cRuntimeError *) override
Definition: cnullenvir.h:156
int simsignal_t
Signal handle.
Definition: clistener.h:24
virtual void moduleDeleted(cModule *module) override
Definition: cnullenvir.h:86
virtual void unrefOsgNode(osg::Node *scene) override
Definition: cnullenvir.h:154
virtual void objectDeleted(cObject *object) override
Definition: cnullenvir.h:70
virtual cXMLElement * getXMLDocument(const char *filename, const char *xpath=nullptr) override
Definition: cnullenvir.h:100
cStatistic is an abstract class for computing statistical properties of a random variable.
Definition: cstatistic.h:34
virtual void flushXMLDocumentCache() override
Definition: cnullenvir.h:104
virtual void flushXMLParsedContentCache() override
Definition: cnullenvir.h:105
virtual void messageCancelled(cMessage *msg) override
Definition: cnullenvir.h:73
Represents the configuration, as accessed by the simulation kernel.
Definition: cconfiguration.h:70
virtual void messageSendDirect(cMessage *msg, cGate *toGate, simtime_t propagationDelay, simtime_t transmissionDelay) override
Definition: cnullenvir.h:75
virtual double getZoomLevel(const cModule *module) override
Definition: cnullenvir.h:117
Represents properties of a font.
Definition: ccanvas.h:157
virtual void displayStringChanged(cComponent *component) override
Definition: cnullenvir.h:91