OMNeT++ API 6.1
Discrete Event Simulation Library
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 std::ostream& getOutputStream() override {return std::cout;}
64  virtual void pausePoint() override {}
65 
66  public:
67  // constructor, destructor
68  cNullEnvir(int ac, char **av, cConfiguration *c);
69  virtual ~cNullEnvir();
70 
71  // eventlog callback interface
72  virtual void objectDeleted(cObject *object) override {}
73  virtual void simulationEvent(cEvent *event) override {}
74  virtual void messageScheduled(cMessage *msg) override {}
75  virtual void messageCancelled(cMessage *msg) override {}
76  virtual void beginSend(cMessage *msg, const SendOptions& options) override {}
77  virtual void messageSendDirect(cMessage *msg, cGate *toGate, const ChannelResult& result) override {}
78  virtual void messageSendHop(cMessage *msg, cGate *srcGate) override {}
79  virtual void messageSendHop(cMessage *msg, cGate *srcGate, const cChannel::Result& result) override {}
80  virtual void endSend(cMessage *msg) override {}
81  virtual void messageCreated(cMessage *msg) override {}
82  virtual void messageCloned(cMessage *msg, cMessage *clone) override {}
83  virtual void messageDeleted(cMessage *msg) override {}
84  virtual void moduleReparented(cModule *module, cModule *oldparent, int oldId) override {}
85  virtual void componentMethodBegin(cComponent *from, cComponent *to, const char *methodFmt, va_list va, bool silent) override {}
86  virtual void componentMethodEnd() override {}
87  virtual void moduleCreated(cModule *newmodule) override {}
88  virtual void moduleDeleted(cModule *module) override {}
89  virtual void gateCreated(cGate *newgate) override {}
90  virtual void gateDeleted(cGate *gate) override {}
91  virtual void connectionCreated(cGate *srcgate) override {}
92  virtual void connectionDeleted(cGate *srcgate) override {}
93  virtual void displayStringChanged(cComponent *component) override {}
94  virtual void undisposedObject(cObject *obj) override {}
95  virtual void log(cLogEntry *entry) override {}
96 
97  // configuration, model parameters
98  virtual void preconfigure(cComponent *component) override {}
99  virtual void configure(cComponent *component) override {}
100  virtual void readParameter(cPar *par) override {unsupported();}
101  virtual bool isModuleLocal(cModule *parentmod, const char *modname, int index) override {return true;}
102  virtual cXMLElement *getXMLDocument(const char *filename, const char *xpath=nullptr) override {unsupported(); return nullptr;}
103  virtual cXMLElement *getParsedXMLString(const char *content, const char *xpath=nullptr) override {unsupported(); return nullptr;}
104  virtual void forgetXMLDocument(const char *filename) override {}
105  virtual void forgetParsedXMLString(const char *content) override {}
106  virtual void flushXMLDocumentCache() override {}
107  virtual void flushXMLParsedContentCache() override {}
108  virtual unsigned getExtraStackForEnvir() const override {return 0;}
109  virtual cConfiguration *getConfig() override {return cfg;}
110  virtual std::string resolveResourcePath(const char *fileName, cComponentType *context) override {return fileName;}
111  virtual bool isGUI() const override {return false;}
112  virtual bool isExpressMode() const override {return false;}
113 
114  virtual void getImageSize(const char *imageName, double& outWidth, double& outHeight) override {unsupported();}
115  virtual void getTextExtent(const cFigure::Font& font, const char *text, double& outWidth, double& outHeight, double& outAscent) override {unsupported();}
116  virtual void appendToImagePath(const char *directory) override {unsupported();}
117  virtual void loadImage(const char *fileName, const char *imageName=nullptr) override {unsupported();}
118  virtual cFigure::Rectangle getSubmoduleBounds(const cModule *submodule) override {return cFigure::Rectangle(NAN, NAN, NAN, NAN);}
119  virtual std::vector<cFigure::Point> getConnectionLine(const cGate *sourceGate) override {return {};}
120  virtual double getZoomLevel(const cModule *module) override {return NAN;}
121  virtual double getAnimationTime() const override {return 0;}
122  virtual double getAnimationSpeed() const override {return 0;}
123  virtual double getRemainingAnimationHoldTime() const override {return 0;}
124 
125  // UI functions (see also protected ones)
126  virtual void bubble(cComponent *component, const char *text) override {}
127  virtual std::string gets(const char *prompt, const char *defaultreply=nullptr) override {unsupported(); return "";}
128  virtual cEnvir& flush() {::fflush(stdout); return *this;}
129 
130  // RNGs
131  virtual int getNumRNGs() const override {return 1;}
132  virtual cRNG *getRNG(int k) override {return rng;}
133 
134  // output vectors
135  virtual void *registerOutputVector(const char *modulename, const char *vectorname, opp_string_map *attributes=nullptr) override {return (void *)1;}
136  virtual void deregisterOutputVector(void *vechandle) 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:122
omnetpp::cNullEnvir::forgetParsedXMLString
virtual void forgetParsedXMLString(const char *content) override
Definition: cnullenvir.h:105
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:98
omnetpp::cNullEnvir::connectionDeleted
virtual void connectionDeleted(cGate *srcgate) override
Definition: cnullenvir.h:92
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:82
omnetpp::cNullEnvir::getParsimProcId
virtual int getParsimProcId() const override
Definition: cnullenvir.h:153
omnetpp::cNullEnvir::configure
virtual void configure(cComponent *component) override
Definition: cnullenvir.h:99
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:112
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:127
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:106
omnetpp::cNullEnvir::getRNG
virtual cRNG * getRNG(int k) override
Definition: cnullenvir.h:132
omnetpp::cNullEnvir::messageSendDirect
virtual void messageSendDirect(cMessage *msg, cGate *toGate, const ChannelResult &result) override
Definition: cnullenvir.h:77
omnetpp::cNullEnvir::flushXMLParsedContentCache
virtual void flushXMLParsedContentCache() override
Definition: cnullenvir.h:107
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:79
omnetpp::cNullEnvir::pausePoint
virtual void pausePoint() override
Definition: cnullenvir.h:64
omnetpp::cNullEnvir::getStreamForSnapshot
virtual std::ostream * getStreamForSnapshot() override
Definition: cnullenvir.h:147
omnetpp::cNullEnvir::readParameter
virtual void readParameter(cPar *par) override
Definition: cnullenvir.h:100
omnetpp::cNullEnvir::undisposedObject
virtual void undisposedObject(cObject *obj) override
Definition: cnullenvir.h:94
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:88
omnetpp::cNullEnvir::messageCreated
virtual void messageCreated(cMessage *msg) override
Definition: cnullenvir.h:81
omnetpp::cNullEnvir::loadImage
virtual void loadImage(const char *fileName, const char *imageName=nullptr) override
Definition: cnullenvir.h:117
omnetpp::cNullEnvir::getXMLDocument
virtual cXMLElement * getXMLDocument(const char *filename, const char *xpath=nullptr) override
Definition: cnullenvir.h:102
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:72
omnetpp::cNullEnvir::messageScheduled
virtual void messageScheduled(cMessage *msg) override
Definition: cnullenvir.h:74
omnetpp::cNullEnvir::messageDeleted
virtual void messageDeleted(cMessage *msg) override
Definition: cnullenvir.h:83
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::cNullEnvir::getOutputStream
virtual std::ostream & getOutputStream() override
Definition: cnullenvir.h:63
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:109
omnetpp::cNullEnvir::getArgCount
virtual int getArgCount() const override
Definition: cnullenvir.h:151
omnetpp::cNullEnvir::displayStringChanged
virtual void displayStringChanged(cComponent *component) override
Definition: cnullenvir.h:93
omnetpp::cNullEnvir::registerOutputVector
virtual void * registerOutputVector(const char *modulename, const char *vectorname, opp_string_map *attributes=nullptr) override
Definition: cnullenvir.h:135
omnetpp::cGate
Represents a module gate.
Definition: cgate.h:62
omnetpp::cNullEnvir::messageCancelled
virtual void messageCancelled(cMessage *msg) override
Definition: cnullenvir.h:75
omnetpp::cNullEnvir::idle
virtual bool idle() override
Definition: cnullenvir.h:158
omnetpp::cNullEnvir::forgetXMLDocument
virtual void forgetXMLDocument(const char *filename) override
Definition: cnullenvir.h:104
omnetpp::cRNG
Abstract interface for random number generator classes.
Definition: crng.h:48
omnetpp::cNullEnvir::getNumRNGs
virtual int getNumRNGs() const override
Definition: cnullenvir.h:131
omnetpp::cNullEnvir::isModuleLocal
virtual bool isModuleLocal(cModule *parentmod, const char *modname, int index) override
Definition: cnullenvir.h:101
omnetpp::cPar
Represents a module or channel parameter.
Definition: cpar.h:70
omnetpp::cNullEnvir::connectionCreated
virtual void connectionCreated(cGate *srcgate) override
Definition: cnullenvir.h:91
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:136
omnetpp::cNullEnvir::getAnimationTime
virtual double getAnimationTime() const override
Definition: cnullenvir.h:121
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:108
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:95
omnetpp::cNullEnvir::bubble
virtual void bubble(cComponent *component, const char *text) override
Definition: cnullenvir.h:126
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:78
omnetpp::cNullEnvir::ensureDebugger
virtual bool ensureDebugger(cRuntimeError *) override
Definition: cnullenvir.h:159
omnetpp::cNullEnvir::getRemainingAnimationHoldTime
virtual double getRemainingAnimationHoldTime() const override
Definition: cnullenvir.h:123
omnetpp::cNullEnvir::componentMethodEnd
virtual void componentMethodEnd() override
Definition: cnullenvir.h:86
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:114
omnetpp::cNullEnvir::resolveResourcePath
virtual std::string resolveResourcePath(const char *fileName, cComponentType *context) override
Definition: cnullenvir.h:110
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:115
omnetpp::cNullEnvir::endSend
virtual void endSend(cMessage *msg) override
Definition: cnullenvir.h:80
omnetpp::cNullEnvir::moduleReparented
virtual void moduleReparented(cModule *module, cModule *oldparent, int oldId) override
Definition: cnullenvir.h:84
omnetpp::cNullEnvir::moduleCreated
virtual void moduleCreated(cModule *newmodule) override
Definition: cnullenvir.h:87
omnetpp::cNullEnvir::getSubmoduleBounds
virtual cFigure::Rectangle getSubmoduleBounds(const cModule *submodule) override
Definition: cnullenvir.h:118
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:116
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:76
omnetpp::cNullEnvir::simulationEvent
virtual void simulationEvent(cEvent *event) override
Definition: cnullenvir.h:73
omnetpp::cNullEnvir::isGUI
virtual bool isGUI() const override
Definition: cnullenvir.h:111
omnetpp::cNullEnvir::gateCreated
virtual void gateCreated(cGate *newgate) override
Definition: cnullenvir.h:89
omnetpp::cNullEnvir::gateDeleted
virtual void gateDeleted(cGate *gate) override
Definition: cnullenvir.h:90
omnetpp::cNullEnvir::componentMethodBegin
virtual void componentMethodBegin(cComponent *from, cComponent *to, const char *methodFmt, va_list va, bool silent) override
Definition: cnullenvir.h:85
omnetpp::cNullEnvir::getParsedXMLString
virtual cXMLElement * getParsedXMLString(const char *content, const char *xpath=nullptr) override
Definition: cnullenvir.h:103
omnetpp::cNullEnvir::getZoomLevel
virtual double getZoomLevel(const cModule *module) override
Definition: cnullenvir.h:120