OMNeT++ Simulation Library  6.0.3
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 = 0;
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  virtual void pausePoint() override {}
64 
65  public:
66  // constructor, destructor
67  cNullEnvir(int ac, char **av, cConfiguration *c);
68  virtual ~cNullEnvir();
69 
70  // eventlog callback interface
71  virtual void objectDeleted(cObject *object) override {}
72  virtual void simulationEvent(cEvent *event) override {}
73  virtual void messageScheduled(cMessage *msg) override {}
74  virtual void messageCancelled(cMessage *msg) override {}
75  virtual void beginSend(cMessage *msg, const SendOptions& options) override {}
76  virtual void messageSendDirect(cMessage *msg, cGate *toGate, const ChannelResult& result) override {}
77  virtual void messageSendHop(cMessage *msg, cGate *srcGate) override {}
78  virtual void messageSendHop(cMessage *msg, cGate *srcGate, const cChannel::Result& result) override {}
79  virtual void endSend(cMessage *msg) override {}
80  virtual void messageCreated(cMessage *msg) override {}
81  virtual void messageCloned(cMessage *msg, cMessage *clone) override {}
82  virtual void messageDeleted(cMessage *msg) override {}
83  virtual void moduleReparented(cModule *module, cModule *oldparent, int oldId) override {}
84  virtual void componentMethodBegin(cComponent *from, cComponent *to, const char *methodFmt, va_list va, bool silent) override {}
85  virtual void componentMethodEnd() override {}
86  virtual void moduleCreated(cModule *newmodule) override {}
87  virtual void moduleDeleted(cModule *module) override {}
88  virtual void gateCreated(cGate *newgate) override {}
89  virtual void gateDeleted(cGate *gate) override {}
90  virtual void connectionCreated(cGate *srcgate) override {}
91  virtual void connectionDeleted(cGate *srcgate) override {}
92  virtual void displayStringChanged(cComponent *component) override {}
93  virtual void undisposedObject(cObject *obj) override {}
94  virtual void log(cLogEntry *entry) override {}
95 
96  // configuration, model parameters
97  virtual void preconfigure(cComponent *component) override {}
98  virtual void configure(cComponent *component) override {}
99  virtual void readParameter(cPar *par) override {unsupported();}
100  virtual bool isModuleLocal(cModule *parentmod, const char *modname, int index) override {return true;}
101  virtual cXMLElement *getXMLDocument(const char *filename, const char *xpath=nullptr) override {unsupported(); return nullptr;}
102  virtual cXMLElement *getParsedXMLString(const char *content, const char *xpath=nullptr) override {unsupported(); return nullptr;}
103  virtual void forgetXMLDocument(const char *filename) override {}
104  virtual void forgetParsedXMLString(const char *content) override {}
105  virtual void flushXMLDocumentCache() override {}
106  virtual void flushXMLParsedContentCache() override {}
107  virtual unsigned getExtraStackForEnvir() const override {return 0;}
108  virtual cConfiguration *getConfig() override {return cfg;}
109  virtual std::string resolveResourcePath(const char *fileName, cComponentType *context) override {return fileName;}
110  virtual bool isGUI() const override {return false;}
111  virtual bool isExpressMode() const override {return false;}
112 
113  virtual void getImageSize(const char *imageName, double& outWidth, double& outHeight) override {unsupported();}
114  virtual void getTextExtent(const cFigure::Font& font, const char *text, double& outWidth, double& outHeight, double& outAscent) override {unsupported();}
115  virtual void appendToImagePath(const char *directory) override {unsupported();}
116  virtual void loadImage(const char *fileName, const char *imageName=nullptr) override {unsupported();}
117  virtual cFigure::Rectangle getSubmoduleBounds(const cModule *submodule) override {return cFigure::Rectangle(NAN, NAN, NAN, NAN);}
118  virtual std::vector<cFigure::Point> getConnectionLine(const cGate *sourceGate) override {return {};}
119  virtual double getZoomLevel(const cModule *module) override {return NAN;}
120  virtual double getAnimationTime() const override {return 0;}
121  virtual double getAnimationSpeed() const override {return 0;}
122  virtual double getRemainingAnimationHoldTime() const override {return 0;}
123 
124  // UI functions (see also protected ones)
125  virtual void bubble(cComponent *component, const char *text) override {}
126  virtual std::string gets(const char *prompt, const char *defaultreply=nullptr) override {unsupported(); return "";}
127  virtual cEnvir& flush() {::fflush(stdout); return *this;}
128 
129  // RNGs
130  virtual int getNumRNGs() const override {return 1;}
131  virtual cRNG *getRNG(int k) override {return rng;}
132 
133  // output vectors
134  virtual void *registerOutputVector(const char *modulename, const char *vectorname) override {return (void *)1;}
135  virtual void deregisterOutputVector(void *vechandle) override {}
136  virtual void setVectorAttribute(void *vechandle, const char *name, const char *value) override {}
137  virtual bool recordInOutputVector(void *vechandle, simtime_t t, double value) override {return false;}
138 
139  // output scalars
140  virtual void recordScalar(cComponent *component, const char *name, double value, opp_string_map *attributes=nullptr) override {}
141  virtual void recordStatistic(cComponent *component, const char *name, cStatistic *statistic, opp_string_map *attributes=nullptr) override {}
142  virtual void recordParameter(cPar *par) override {}
143  virtual void recordComponentType(cComponent *component) override {}
144  virtual void addResultRecorders(cComponent *component, simsignal_t signal, const char *statisticName, cProperty *statisticTemplateProperty) override {}
145 
146  // snapshot file
147  virtual std::ostream *getStreamForSnapshot() override {unsupported(); return nullptr;}
148  virtual void releaseStreamForSnapshot(std::ostream *os) override {unsupported();}
149 
150  // misc
151  virtual int getArgCount() const override {return argc;}
152  virtual char **getArgVector() const override {return argv;}
153  virtual int getParsimProcId() const override {return 0;}
154  virtual int getParsimNumPartitions() const override {return 1;}
155  virtual unsigned long getUniqueNumber() override {return nextUniqueNumber++;}
156  virtual void refOsgNode(osg::Node *scene) override {}
157  virtual void unrefOsgNode(osg::Node *scene) override {}
158  virtual bool idle() override {return false;}
159  virtual bool ensureDebugger(cRuntimeError *) override { return false; }
160 };
161 
162 
163 } // namespace omnetpp
164 
165 #endif
166 
167 
omnetpp::cNullEnvir::getAnimationSpeed
virtual double getAnimationSpeed() const override
Definition: cnullenvir.h:121
omnetpp::cNullEnvir::forgetParsedXMLString
virtual void forgetParsedXMLString(const char *content) override
Definition: cnullenvir.h:104
omnetpp::cModule
This class represents modules in the simulation.
Definition: cmodule.h:48
omnetpp::cNullEnvir::preconfigure
virtual void preconfigure(cComponent *component) override
Definition: cnullenvir.h:97
omnetpp::cNullEnvir::connectionDeleted
virtual void connectionDeleted(cGate *srcgate) override
Definition: cnullenvir.h:91
omnetpp::ChannelResult
Allows returning multiple values from the processMessage() method.
Definition: cchannel.h:33
omnetpp::simsignal_t
int simsignal_t
Signal handle.
Definition: clistener.h:27
omnetpp::cNullEnvir::getParsimNumPartitions
virtual int getParsimNumPartitions() const override
Definition: cnullenvir.h:154
omnetpp::cNullEnvir::recordComponentType
virtual void recordComponentType(cComponent *component) override
Definition: cnullenvir.h:143
omnetpp::cObject
cObject is a lightweight class which serves as the root of the OMNeT++ class hierarchy....
Definition: cobject.h:92
omnetpp::cNullEnvir::messageCloned
virtual void messageCloned(cMessage *msg, cMessage *clone) override
Definition: cnullenvir.h:81
omnetpp::cNullEnvir::getParsimProcId
virtual int getParsimProcId() const override
Definition: cnullenvir.h:153
omnetpp::cNullEnvir::configure
virtual void configure(cComponent *component) override
Definition: cnullenvir.h:98
omnetpp::cNullEnvir::refOsgNode
virtual void refOsgNode(osg::Node *scene) override
Definition: cnullenvir.h:156
omnetpp::cConfiguration
Represents the configuration, as accessed by the simulation kernel.
Definition: cconfiguration.h:76
omnetpp::cNullEnvir::isExpressMode
virtual bool isExpressMode() const override
Definition: cnullenvir.h:111
omnetpp::cNullEnvir::recordInOutputVector
virtual bool recordInOutputVector(void *vechandle, simtime_t t, double value) override
Definition: cnullenvir.h:137
omnetpp::cFigure::Font
Represents properties of a font.
Definition: ccanvas.h:162
omnetpp::cNullEnvir::gets
virtual std::string gets(const char *prompt, const char *defaultreply=nullptr) override
Definition: cnullenvir.h:126
omnetpp::cNullEnvir::askYesNo
virtual bool askYesNo(const char *prompt) override
Definition: cnullenvir.h:62
omnetpp::cEvent
Represents an event in the discrete event simulator.
Definition: cevent.h:46
omnetpp::cNullEnvir
A do-nothing cEnvir implementation.
Definition: cnullenvir.h:49
omnetpp::cNullEnvir::recordScalar
virtual void recordScalar(cComponent *component, const char *name, double value, opp_string_map *attributes=nullptr) override
Definition: cnullenvir.h:140
omnetpp::cNullEnvir::flushXMLDocumentCache
virtual void flushXMLDocumentCache() override
Definition: cnullenvir.h:105
omnetpp::cNullEnvir::getRNG
virtual cRNG * getRNG(int k) override
Definition: cnullenvir.h:131
omnetpp::cNullEnvir::messageSendDirect
virtual void messageSendDirect(cMessage *msg, cGate *toGate, const ChannelResult &result) override
Definition: cnullenvir.h:76
omnetpp::cNullEnvir::flushXMLParsedContentCache
virtual void flushXMLParsedContentCache() override
Definition: cnullenvir.h:106
omnetpp::cLogEntry
This class holds various data that is captured when a particular log statement executes....
Definition: clog.h:376
omnetpp::cNullEnvir::messageSendHop
virtual void messageSendHop(cMessage *msg, cGate *srcGate, const cChannel::Result &result) override
Definition: cnullenvir.h:78
omnetpp::cNullEnvir::pausePoint
virtual void pausePoint() override
Definition: cnullenvir.h:63
omnetpp::cNullEnvir::getStreamForSnapshot
virtual std::ostream * getStreamForSnapshot() override
Definition: cnullenvir.h:147
omnetpp::cNullEnvir::readParameter
virtual void readParameter(cPar *par) override
Definition: cnullenvir.h:99
omnetpp::cNullEnvir::undisposedObject
virtual void undisposedObject(cObject *obj) override
Definition: cnullenvir.h:93
omnetpp::opp_string_map
Lightweight string-to-string map, used internally in some parts of OMNeT++.
Definition: opp_string.h:219
omnetpp::cNullEnvir::moduleDeleted
virtual void moduleDeleted(cModule *module) override
Definition: cnullenvir.h:87
omnetpp::cNullEnvir::messageCreated
virtual void messageCreated(cMessage *msg) override
Definition: cnullenvir.h:80
omnetpp::cNullEnvir::loadImage
virtual void loadImage(const char *fileName, const char *imageName=nullptr) override
Definition: cnullenvir.h:116
omnetpp::cNullEnvir::getXMLDocument
virtual cXMLElement * getXMLDocument(const char *filename, const char *xpath=nullptr) override
Definition: cnullenvir.h:101
omnetpp::cNullEnvir::alert
virtual void alert(const char *msg) override
Definition: cnullenvir.h:61
omnetpp::SimTime
int64_t-based, base-10 fixed-point simulation time.
Definition: simtime.h:66
omnetpp::cNullEnvir::releaseStreamForSnapshot
virtual void releaseStreamForSnapshot(std::ostream *os) override
Definition: cnullenvir.h:148
omnetpp::cNullEnvir::objectDeleted
virtual void objectDeleted(cObject *object) override
Definition: cnullenvir.h:71
omnetpp::cNullEnvir::messageScheduled
virtual void messageScheduled(cMessage *msg) override
Definition: cnullenvir.h:73
omnetpp::cNullEnvir::messageDeleted
virtual void messageDeleted(cMessage *msg) override
Definition: cnullenvir.h:82
omnetpp::cNullEnvir::recordStatistic
virtual void recordStatistic(cComponent *component, const char *name, cStatistic *statistic, opp_string_map *attributes=nullptr) override
Definition: cnullenvir.h:141
omnetpp::cNullEnvir::addResultRecorders
virtual void addResultRecorders(cComponent *component, simsignal_t signal, const char *statisticName, cProperty *statisticTemplateProperty) override
Definition: cnullenvir.h:144
omnetpp::SendOptions
Options for the cSimpleModule::send() and cSimpleModule::sendDirect() calls.
Definition: csimplemodule.h:82
omnetpp::cNullEnvir::getConfig
virtual cConfiguration * getConfig() override
Definition: cnullenvir.h:108
omnetpp::cNullEnvir::getArgCount
virtual int getArgCount() const override
Definition: cnullenvir.h:151
omnetpp::cNullEnvir::displayStringChanged
virtual void displayStringChanged(cComponent *component) override
Definition: cnullenvir.h:92
omnetpp::cGate
Represents a module gate.
Definition: cgate.h:62
omnetpp::cNullEnvir::messageCancelled
virtual void messageCancelled(cMessage *msg) override
Definition: cnullenvir.h:74
omnetpp::cNullEnvir::idle
virtual bool idle() override
Definition: cnullenvir.h:158
omnetpp::cNullEnvir::forgetXMLDocument
virtual void forgetXMLDocument(const char *filename) override
Definition: cnullenvir.h:103
omnetpp::cRNG
Abstract interface for random number generator classes.
Definition: crng.h:48
omnetpp::cNullEnvir::getNumRNGs
virtual int getNumRNGs() const override
Definition: cnullenvir.h:130
omnetpp::cNullEnvir::isModuleLocal
virtual bool isModuleLocal(cModule *parentmod, const char *modname, int index) override
Definition: cnullenvir.h:100
omnetpp::cPar
Represents a module or channel parameter.
Definition: cpar.h:70
omnetpp::cNullEnvir::registerOutputVector
virtual void * registerOutputVector(const char *modulename, const char *vectorname) override
Definition: cnullenvir.h:134
omnetpp::cNullEnvir::connectionCreated
virtual void connectionCreated(cGate *srcgate) override
Definition: cnullenvir.h:90
omnetpp::cComponentType
Common base class for cModuleType and cChannelType.
Definition: ccomponenttype.h:49
omnetpp::cNullEnvir::deregisterOutputVector
virtual void deregisterOutputVector(void *vechandle) override
Definition: cnullenvir.h:135
omnetpp::cNullEnvir::getAnimationTime
virtual double getAnimationTime() const override
Definition: cnullenvir.h:120
omnetpp::cNullEnvir::getArgVector
virtual char ** getArgVector() const override
Definition: cnullenvir.h:152
omnetpp::cMessage
The message class in OMNeT++. cMessage objects may represent events, messages, jobs or other entities...
Definition: cmessage.h:95
omnetpp::cNullEnvir::getExtraStackForEnvir
virtual unsigned getExtraStackForEnvir() const override
Definition: cnullenvir.h:107
omnetpp::cNullEnvir::recordParameter
virtual void recordParameter(cPar *par) override
Definition: cnullenvir.h:142
omnetpp::cNullEnvir::log
virtual void log(cLogEntry *entry) override
Definition: cnullenvir.h:94
omnetpp::cNullEnvir::bubble
virtual void bubble(cComponent *component, const char *text) override
Definition: cnullenvir.h:125
omnetpp::cXMLElement
Represents an XML element in an XML configuration file.
Definition: cxmlelement.h:75
omnetpp::cComponent
Common base for module and channel classes.
Definition: ccomponent.h:49
omnetpp::cNullEnvir::messageSendHop
virtual void messageSendHop(cMessage *msg, cGate *srcGate) override
Definition: cnullenvir.h:77
omnetpp::cNullEnvir::setVectorAttribute
virtual void setVectorAttribute(void *vechandle, const char *name, const char *value) override
Definition: cnullenvir.h:136
omnetpp::cNullEnvir::ensureDebugger
virtual bool ensureDebugger(cRuntimeError *) override
Definition: cnullenvir.h:159
omnetpp::cNullEnvir::getRemainingAnimationHoldTime
virtual double getRemainingAnimationHoldTime() const override
Definition: cnullenvir.h:122
omnetpp::cNullEnvir::componentMethodEnd
virtual void componentMethodEnd() override
Definition: cnullenvir.h:85
omnetpp::cStatistic
cStatistic is an abstract class for computing statistical properties of a random variable.
Definition: cstatistic.h:34
omnetpp::cNullEnvir::getImageSize
virtual void getImageSize(const char *imageName, double &outWidth, double &outHeight) override
Definition: cnullenvir.h:113
omnetpp::cNullEnvir::resolveResourcePath
virtual std::string resolveResourcePath(const char *fileName, cComponentType *context) override
Definition: cnullenvir.h:109
omnetpp::cRuntimeError
Thrown when the simulation kernel or other components detect a runtime error.
Definition: cexception.h:286
omnetpp::cNullEnvir::getTextExtent
virtual void getTextExtent(const cFigure::Font &font, const char *text, double &outWidth, double &outHeight, double &outAscent) override
Definition: cnullenvir.h:114
omnetpp::cNullEnvir::endSend
virtual void endSend(cMessage *msg) override
Definition: cnullenvir.h:79
omnetpp::cNullEnvir::moduleReparented
virtual void moduleReparented(cModule *module, cModule *oldparent, int oldId) override
Definition: cnullenvir.h:83
omnetpp::cNullEnvir::moduleCreated
virtual void moduleCreated(cModule *newmodule) override
Definition: cnullenvir.h:86
omnetpp::cNullEnvir::getSubmoduleBounds
virtual cFigure::Rectangle getSubmoduleBounds(const cModule *submodule) override
Definition: cnullenvir.h:117
omnetpp::cEnvir
cEnvir represents the "environment" or user interface of the simulation.
Definition: cenvir.h:75
omnetpp::cFigure::Rectangle
Represents a rectangle as an (x,y,width,height) tuple.
Definition: ccanvas.h:94
omnetpp::cProperty
Stores a (NED) property with its (possibly compound) value.
Definition: cproperty.h:38
omnetpp::cNullEnvir::appendToImagePath
virtual void appendToImagePath(const char *directory) override
Definition: cnullenvir.h:115
omnetpp::cNullEnvir::unrefOsgNode
virtual void unrefOsgNode(osg::Node *scene) override
Definition: cnullenvir.h:157
omnetpp::cNullEnvir::getUniqueNumber
virtual unsigned long getUniqueNumber() override
Definition: cnullenvir.h:155
omnetpp::cNullEnvir::beginSend
virtual void beginSend(cMessage *msg, const SendOptions &options) override
Definition: cnullenvir.h:75
omnetpp::cNullEnvir::simulationEvent
virtual void simulationEvent(cEvent *event) override
Definition: cnullenvir.h:72
omnetpp::cNullEnvir::isGUI
virtual bool isGUI() const override
Definition: cnullenvir.h:110
omnetpp::cNullEnvir::gateCreated
virtual void gateCreated(cGate *newgate) override
Definition: cnullenvir.h:88
omnetpp::cNullEnvir::gateDeleted
virtual void gateDeleted(cGate *gate) override
Definition: cnullenvir.h:89
omnetpp::cNullEnvir::componentMethodBegin
virtual void componentMethodBegin(cComponent *from, cComponent *to, const char *methodFmt, va_list va, bool silent) override
Definition: cnullenvir.h:84
omnetpp::cNullEnvir::getParsedXMLString
virtual cXMLElement * getParsedXMLString(const char *content, const char *xpath=nullptr) override
Definition: cnullenvir.h:102
omnetpp::cNullEnvir::getZoomLevel
virtual double getZoomLevel(const cModule *module) override
Definition: cnullenvir.h:119