OMNeT++ Simulation Library
6.0.3
|
#include <cnullenvir.h>
A do-nothing cEnvir implementation.
This class defines cEnvir's pure virtual methods with an empty body, with a trivial implementation, or to throw an exception with an "unsupported method" message.
This class is not used by OMNeT++, it is provided for convenience of writing standalone programs that embed the simulation kernel as a library.
You may want to subclass from cNullEnvir, and redefine some the following methods:
Public Member Functions | |
virtual void | objectDeleted (cObject *object) override |
virtual void | simulationEvent (cEvent *event) override |
virtual void | messageScheduled (cMessage *msg) override |
virtual void | messageCancelled (cMessage *msg) override |
virtual void | beginSend (cMessage *msg, const SendOptions &options) override |
virtual void | messageSendDirect (cMessage *msg, cGate *toGate, const ChannelResult &result) override |
virtual void | messageSendHop (cMessage *msg, cGate *srcGate) override |
virtual void | messageSendHop (cMessage *msg, cGate *srcGate, const cChannel::Result &result) override |
virtual void | endSend (cMessage *msg) override |
virtual void | messageCreated (cMessage *msg) override |
virtual void | messageCloned (cMessage *msg, cMessage *clone) override |
virtual void | messageDeleted (cMessage *msg) override |
virtual void | moduleReparented (cModule *module, cModule *oldparent, int oldId) override |
virtual void | componentMethodBegin (cComponent *from, cComponent *to, const char *methodFmt, va_list va, bool silent) override |
virtual void | componentMethodEnd () override |
virtual void | moduleCreated (cModule *newmodule) override |
virtual void | moduleDeleted (cModule *module) override |
virtual void | gateCreated (cGate *newgate) override |
virtual void | gateDeleted (cGate *gate) override |
virtual void | connectionCreated (cGate *srcgate) override |
virtual void | connectionDeleted (cGate *srcgate) override |
virtual void | displayStringChanged (cComponent *component) override |
virtual void | undisposedObject (cObject *obj) override |
virtual void | log (cLogEntry *entry) override |
virtual void | preconfigure (cComponent *component) override |
virtual void | configure (cComponent *component) override |
virtual void | readParameter (cPar *par) override |
virtual bool | isModuleLocal (cModule *parentmod, const char *modname, int index) override |
virtual cXMLElement * | getXMLDocument (const char *filename, const char *xpath=nullptr) override |
virtual cXMLElement * | getParsedXMLString (const char *content, const char *xpath=nullptr) override |
virtual void | forgetXMLDocument (const char *filename) override |
virtual void | forgetParsedXMLString (const char *content) override |
virtual void | flushXMLDocumentCache () override |
virtual void | flushXMLParsedContentCache () override |
virtual unsigned | getExtraStackForEnvir () const override |
virtual cConfiguration * | getConfig () override |
virtual std::string | resolveResourcePath (const char *fileName, cComponentType *context) override |
virtual bool | isGUI () const override |
virtual bool | isExpressMode () const override |
virtual void | getImageSize (const char *imageName, double &outWidth, double &outHeight) override |
virtual void | getTextExtent (const cFigure::Font &font, const char *text, double &outWidth, double &outHeight, double &outAscent) override |
virtual void | appendToImagePath (const char *directory) override |
virtual void | loadImage (const char *fileName, const char *imageName=nullptr) override |
virtual cFigure::Rectangle | getSubmoduleBounds (const cModule *submodule) override |
virtual double | getZoomLevel (const cModule *module) override |
virtual double | getAnimationTime () const override |
virtual double | getAnimationSpeed () const override |
virtual double | getRemainingAnimationHoldTime () const override |
virtual void | bubble (cComponent *component, const char *text) override |
virtual std::string | gets (const char *prompt, const char *defaultreply=nullptr) override |
virtual int | getNumRNGs () const override |
virtual cRNG * | getRNG (int k) override |
virtual void * | registerOutputVector (const char *modulename, const char *vectorname) override |
virtual void | deregisterOutputVector (void *vechandle) override |
virtual void | setVectorAttribute (void *vechandle, const char *name, const char *value) override |
virtual bool | recordInOutputVector (void *vechandle, simtime_t t, double value) override |
virtual void | recordScalar (cComponent *component, const char *name, double value, opp_string_map *attributes=nullptr) override |
virtual void | recordStatistic (cComponent *component, const char *name, cStatistic *statistic, opp_string_map *attributes=nullptr) override |
virtual void | recordParameter (cPar *par) override |
virtual void | recordComponentType (cComponent *component) override |
virtual void | addResultRecorders (cComponent *component, simsignal_t signal, const char *statisticName, cProperty *statisticTemplateProperty) override |
virtual std::ostream * | getStreamForSnapshot () override |
virtual void | releaseStreamForSnapshot (std::ostream *os) override |
virtual int | getArgCount () const override |
virtual char ** | getArgVector () const override |
virtual int | getParsimProcId () const override |
virtual int | getParsimNumPartitions () const override |
virtual unsigned long | getUniqueNumber () override |
virtual void | refOsgNode (osg::Node *scene) override |
virtual void | unrefOsgNode (osg::Node *scene) override |
virtual bool | idle () override |
virtual bool | ensureDebugger (cRuntimeError *) override |
Public Member Functions inherited from cEnvir | |
cEnvir () | |
virtual | ~cEnvir () |
virtual void | componentInitBegin (cComponent *component, int stage) |
virtual const char * | getCurrentEventName () |
virtual const char * | getCurrentEventClassName () |
virtual cModule * | getCurrentEventModule () |
virtual cConfigurationEx * | getConfigEx () |
bool | isLoggingEnabled () const |
virtual void | printfmsg (const char *fmt,...) |
virtual void | addLifecycleListener (cISimulationLifecycleListener *listener) |
virtual void | removeLifecycleListener (cISimulationLifecycleListener *listener) |
virtual std::vector< cISimulationLifecycleListener * > | getLifecycleListeners () const |
virtual void | notifyLifecycleListeners (SimulationLifecycleEventType eventType, cObject *details=nullptr) |
Protected Member Functions | |
virtual void | alert (const char *msg) override |
virtual bool | askYesNo (const char *prompt) override |
virtual void | pausePoint () override |
|
inlineoverrideprotectedvirtual |
Displays the given alert text in a conspicuous way, e.g. in a dialog box. This function should be used sparingly from models, if ever.
Implements cEnvir.
|
inlineoverrideprotectedvirtual |
Asks the user a yes/no question with the given prompt. The return value is true for "yes", and false for "no". This function should be used sparingly from models, if ever.
Implements cEnvir.
|
inlineoverrideprotectedvirtual |
Potentially blocks the execution of model code when called. When using user interfaces (graphical environments) that support it, gives the user opportunity to examine the state of the simulation even in the middle of performing an event, and resume on demand. This is similar to how breakpoints work in debuggers.
Implements cEnvir.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Notifies the environment that a message was delivered to its destination module, that is, a message arrival event occurred. Details can be extracted from the message object itself. The user interface implementation may use the notification to animate the message on a network diagram, to write a log entry, etc.
Implements cEnvir.
|
inlineoverridevirtual |
Notifies the environment that a message was scheduled.
Implements cEnvir.
|
inlineoverridevirtual |
Notifies the environment that a scheduled message was cancelled.
Implements cEnvir.
|
inlineoverridevirtual |
Notifies the environment that a message is being sent from a simple module. beginSend() will be followed by a messageSendDirect() (optional, only present when cSimpleModule::sendDirect() was called), several messageSendHop() calls (one for each connection in the path), and finally an endSend(). At least one call to either messageSendDirect() or messageSendHop() must occur between corresponding beginSend()/endSend() pairs. If the result.discard parameter (member) is true in a messageSendHop() call, the sequence ends there without a call to endSend(), and a messageDeleted() call will follow.
Implements cEnvir.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Notifies the environment that a module changed parent.
Implements cEnvir.
|
inlineoverridevirtual |
Notifies the environment that one component (module) called a member function of another component. This hook enables a graphical user interface to animate the method call in the network diagram. Pass methodFmt==nullptr for Enter_Method_Silent.
Implements cEnvir.
|
inlineoverridevirtual |
Notifies the environment that the method entered in the last componentMethodBegin() call has exited.
Implements cEnvir.
|
inlineoverridevirtual |
Notifies the environment that a module was created. This method is called from cModuleType::create(), when the module has already been created but buildInside() has not been invoked yet.
Implements cEnvir.
|
inlineoverridevirtual |
Notifies the environment that a module was (more precisely: is being) deleted. This method is called from cModule destructor, so the "real" type (getClassName() and everything from the actual subclass) is already lost at this point, however getName(), getFullName(), getFullPath(), gates, parameters (everything that comes from cModule) are still valid.
If a compound module (or a module with dynamically created submodules) is deleted, one should not assume anything about the relative order moduleDeleted() is called for the module and its submodules.
Implements cEnvir.
|
inlineoverridevirtual |
Notifies the environment that a gates was created.
Implements cEnvir.
|
inlineoverridevirtual |
Notifies the environment that a gates was (more precisely: is being) deleted.
Implements cEnvir.
|
inlineoverridevirtual |
Notifies the environment that a connection has been created using srcgate->connectTo().
Implements cEnvir.
|
inlineoverridevirtual |
Notifies the environment that a connection has been deleted using srcgate->disconnect().
Implements cEnvir.
|
inlineoverridevirtual |
Notifies the environment that a module or channel display string has changed.
Implements cEnvir.
|
inlineoverridevirtual |
Called from module destructors, to notify the environment about objects that the user did not delete in the module destructor.
Reimplemented from cEnvir.
|
inlineoverridevirtual |
Log a line described by the entry.
Implements cEnvir.
|
inlineoverridevirtual |
Called when a module or channel object has been created and added to the model, but no parameters or gates have been set up yet. It allows the environment perform extra configuration. One use is to set up RNG mapping.
Implements cEnvir.
|
inlineoverridevirtual |
Called when a module or channel has been created and installed in the model, after parameters and gates have been set up, but before submodules and internal connections are added. This method lets the environment perform extra configuration.
Implements cEnvir.
|
inlineoverridevirtual |
Assigns the module or channel parameter from the configuration, or by asking the user.
Implements cEnvir.
|
inlineoverridevirtual |
Used for parallel distributed simulation. Returns true if the named future submodule of parentmod is (or will have any submodule) in the local partition, and false otherwise. index should be -1 if the submodule is not in a module vector.
Note that for compound modules that contain simple modules in several partitions, this function will return true on all those partitions.
Implements cEnvir.
|
inlineoverridevirtual |
Resolves reference to an XML model configuration file. First argument is the file name of the XML document. The optional second argument may contain an XPath-like expression to denote an element within the XML document. If path is not present, the root element is returned.
See documentation of cXMLElement::getElementByPath() for path syntax. There is a difference however: paths starting with "." are not accepted, and the first path component must name the root element of the document (with getElementByPath() it would match a child element of the current element). That is, a leading "/" is always assumed at the beginning of the path expression, even if it is not explicitly there.
The method throws an exception if the document cannot be found, there was a parse error, or the given path expression is invalid. It returns nullptr if the element denoted by the path expression does not exist in the document.
The returned object tree should not be modified because cEnvir may cache the file and return the same pointer to several callers.
Implements cEnvir.
|
inlineoverridevirtual |
Returns the parsed form of an XML content string. The first argument is the XML content string. The optional second argument may contain an XPath-like expression to denote an element within the XML document. If path is not present, the root element is returned.
See documentation of cXMLElement::getElementByPath() for path syntax. There is a difference however: paths starting with "." are not accepted, and the first path component must name the root element of the document (with getElementByPath() it would match a child element of the current element). That is, a leading "/" is always assumed at the beginning of the path expression, even if it is not explicitly there.
The method throws an exception if there was a parse error or if the given path expression is invalid. It returns nullptr if the element denoted by the path expression does not exist in the document.
The returned object tree should not be modified because cEnvir may cache the tree and return the same pointer to several callers.
Implements cEnvir.
|
inlineoverridevirtual |
Removes the given document from the XML document cache (if cached), and deletes the object tree from memory. Further getXMLDocument() calls will reload the file from the disk. After forgetXMLDocument(), cXMLElement objects returned for the same document by getXMLDocument() should no longer be referenced. The call has no effect if the given file does not exist or has not yet been loaded.
CAUTION: As of version 4.1, this is not a safe operation! Module parameters (cPar) of type "xml" hold pointers to the element trees returned by getXMLDocument(), and this method makes those pointers invalid.
Implements cEnvir.
|
inlineoverridevirtual |
Removes the given document from the XML document cache (if cached), and deletes the object tree from memory. After forgetXMLDocument(), cXMLElement objects returned for the same content string by getParsedXMLString() should no longer be referenced. The call has no effect if the given string has not yet been parsed.
CAUTION: As of version 4.1, this is not a safe operation! Module parameters (cPar) of type "xml" hold pointers to the element trees returned by getXMLDocument(), and this method makes those pointers invalid.
Implements cEnvir.
|
inlineoverridevirtual |
Clears the cache of loaded XML documents, and deletes the corresponding cXMLElement trees.
CAUTION: As of version 4.1, this is not a safe operation, as module parameters (cPar) of type "xml" hold pointers to the element trees returned by getXMLDocument(), and this method makes those pointers invalid.
Implements cEnvir.
|
inlineoverridevirtual |
Clears the cache of parsed XML content strings, and deletes the corresponding cXMLElement trees.
CAUTION: As of version 4.1, this is not a safe operation, as module parameters (cPar) of type "xml" hold pointers to the element trees returned by getXMLDocument(), and this method makes those pointers invalid.
Implements cEnvir.
|
inlineoverridevirtual |
Called from cSimpleModule, it returns how much extra stack space the user interface recommends for activity() simple modules.
Implements cEnvir.
|
inlineoverridevirtual |
Access to the configuration (by default, omnetpp.ini). This method is provided here for the benefit of schedulers, parallel simulation algorithms and other simulation kernel extensions. Models (simple modules) should NOT directly access the configuration – they should rely on module parameters to get input.
Implements cEnvir.
|
inlineoverridevirtual |
Searches a number of folders for a resource given with its file name or relative path, and returns the path for the first match. If the resource is not found, the empty string is returned.
The list of the search folders includes the current working directory, the folder of the main ini file, the folder that the NED file of the given "context" type was loaded from, folders in the NED path, and folders in the image path (OMNETPP_IMAGE_PATH).
Implements cEnvir.
|
inlineoverridevirtual |
Returns true if the current environment is a graphical user interface. (For example, it returns true if the simulation is running in Qtenv, and false if it's running in Cmdenv.) Modules can examine this flag to decide whether or not they need to bother with visualization, e.g. dynamically updating display strings or drawing on canvases.
Implements cEnvir.
|
inlineoverridevirtual |
Returns true if the simulation is running under a GUI in Express mode. Visualization code (e.g. inside module refreshDisplay() methods) may check this flag and adapt the visualization accordingly.
Implements cEnvir.
|
inlineoverridevirtual |
Returns the size of the image with the given name (e.g. "block/switch_l") in pixels. If the image does not exist, it returns the size of the "unknown" icon (as that is the image actually displayed). Non-GUI environments like Cmdenv may return made-up (but not completely unrealistic) numbers.
This method is used by some methods of cImageFigure, e.g. getBounds().
Implements cEnvir.
|
inlineoverridevirtual |
Returns the size and ascent of the bounding box of the text when rendered with the given font in the GUI. Non-GUI environments like Cmdenv may return made-up (but not completely unrealistic) numbers.
This method is used by some methods of cTextFigure, e.g. getBounds().
Implements cEnvir.
|
inlineoverridevirtual |
Tells the user interface to load the images from the given directory, as if the directory was part of the the OMNeT++ image path. The loaded images can then be used in display strings and with cImageFigure/cIconFigure.
An error is thrown if the given directory does not exist or cannot be accessed. This method is idempotent: the second and further invocations with the same parameter have no effect. The method may have no effect if the simulation is running under Cmdenv or another non-graphical user interface.
Implements cEnvir.
|
inlineoverridevirtual |
Tells the user interface to load the image from the given image file. The loaded image can then be used in display strings and with cImageFigure/cIconFigure, by referencing it with the image name. If the location of the image file is not known or cannot be easily determined, resolveResourcePath() may be used to find it prior to loadImage().
The image name may be specified explicitly (in the imageName argument), or if it is missing (is nullptr or empty string), the base file name will be used (fileName with directories and extension stripped). Note that if an image with the given name has already been loaded, this method will do nothing, i.e. already loaded images are NOT replaced. This also means that the method is idempotent: the second and further invocations with the same parameter have no effect.
An error is thrown if the given file does not exist or cannot be loaded as a supported image format. The method may have no effect if the simulation is running under Cmdenv or another non-graphical user interface.
Implements cEnvir.
|
inlineoverridevirtual |
Returns the effective bounding rectangle of the given module when it is visualized in the graphical inspector of its containing compound module, or (NAN,NAN,NAN,NAN) if such a rectangle is not available. This method is the only way to access positions of "floating" modules, i.e. those placed by a layouting algorithm that runs as part of the UI. The method may unconditionally return (NAN,NAN,NAN,NAN) when the simulation is running under Cmdenv or another non-graphical user interface.
Also note that this method may return different values at different times, e.g. as a result of the user opening and closing inspectors, hitting the "Relayout" button, or even changing the zoom level or icon size of graphical module inspectors displaying the parent module. Visualization code relying on this method is advised to re-read coordinates in every refreshDisplay() call, and check whether they changed since last time.
Implements cEnvir.
|
inlineoverridevirtual |
Returns the current zoom level of a graphical module inspector displaying the given module (its contents from the inside, not as a submodule icon), or NAN if not available. A value of 1.0 means 100% zoom (actual size), 0.5 means 50% (half size), and so on. The method may unconditionally return NAN if the simulation is running under Cmdenv or another non-graphical user interface.
Also note that this method may return different values at different times, e.g. as a result of the user changing the zoom level, or even opening and closing inspectors. Visualization code relying on this method is advised to re-read the value in every refreshDisplay() call, and check whether it changed since last time.
Implements cEnvir.
|
inlineoverridevirtual |
Returns the current animation time. Animation time starts from zero, and monotonically increases with simulation time and also during zero-simtime animations a.k.a. "holds". The method may return 0 if the simulation is running under Cmdenv or another non-graphical user interface.
Implements cEnvir.
|
inlineoverridevirtual |
Returns the current animation speed. It is usually computed as the minimum of the animation speeds of visible canvases, unless the user interactively overrides it in the UI, for example imposes a lower limit. The method returns 0 if there is currently no animation speed, or the simulation is running under Cmdenv or another non-graphical user interface.
Implements cEnvir.
|
inlineoverridevirtual |
Returns the remaining animation "hold" time. This is the maximum of the animation times remaining from the holds times requested by visible canvases.
Implements cEnvir.
|
inlineoverridevirtual |
In graphical user interfaces like Qtenv, it pops up a transient "bubble" over the module icon.
Implements cEnvir.
|
inlineoverridevirtual |
Interactively prompts the user to enter a string. This function should be used sparingly from models, if ever.
Implements cEnvir.
|
inlineoverridevirtual |
Returns the number of RNGs available for the simulation ("num-rngs=" omnetpp.ini setting).
Implements cEnvir.
|
inlineoverridevirtual |
Returns pointer to "physical" RNG k (0 <= k < getNumRNGs()).
Implements cEnvir.
|
inlineoverridevirtual |
This method is intended to be called by cOutVector objects to register themselves. The returned value is a handle that identifies the vector in subsequent recordInOutputVector() and deregisterOutputVector() calls. The handle may have any value (it does not have to be a valid pointer), but it should NOT be nullptr.
Implements cEnvir.
|
inlineoverridevirtual |
cOutVector objects must deregister themselves when they are no longer needed.
Implements cEnvir.
|
inlineoverridevirtual |
This method is called when an attribute of the output vector is set.
Implements cEnvir.
|
inlineoverridevirtual |
This method is intended to be called by cOutVector objects to write a value into the output vector. The return value is true if the data was actually recorded, and false if it was not recorded (because of filtering, etc.)
Implements cEnvir.
|
inlineoverridevirtual |
Records a double scalar result, in a default configuration into the scalar result file.
Implements cEnvir.
|
inlineoverridevirtual |
Records a statistic object (histogram, etc) into the scalar result file. This operation may invoke the setUpBins() method on the histogram object.
Implements cEnvir.
|
inlineoverridevirtual |
Records a module or channel parameter, in a default configuration into the scalar result file.
Implements cEnvir.
|
inlineoverridevirtual |
Records the runtime NED type of module or channel, in a default configuration into the scalar result file.
Implements cEnvir.
|
inlineoverridevirtual |
Adds result recording listeners for the given signal on the given component. The result will be recorded to the the given component, with a name equal to or derived from the given statisticName. The statisticTemplateProperty parameter is expected to point to a @statisticTemplate NED property with content similar to @statistic properties. The computation and result type (scalar, vector, etc) will be taken from the 'record' key of statisticTemplateProperty in the same way as with @statistic. Also similar to @statistic, key-value pairs of statisticTemplateProperty will be recorded as result attributes.
In statisticTemplateProperty, the 'source' key will be ignored (because the signal given as parameter will be used as source). The actual name and index of statisticTemplateProperty will also be ignored. (With @statistic, the index holds the result name, but here the name is explicitly specified in the statisticName parameter.)
The purpose of this function is to allow setting up signal-based result recording dynamically when static configuration via @statistic properties is not possible, e.g. because the set of signals to record is only known at runtime.
Implements cEnvir.
|
inlineoverridevirtual |
Returns a stream where a snapshot can be written. Called from cSimulation::snapshot().
Implements cEnvir.
|
inlineoverridevirtual |
Releases a stream after a snapshot was written.
Implements cEnvir.
|
inlineoverridevirtual |
Access to original command-line arguments.
Implements cEnvir.
|
inlineoverridevirtual |
Access to original command-line arguments.
Implements cEnvir.
|
inlineoverridevirtual |
Returns the partitionID when parallel simulation is active.
Implements cEnvir.
|
inlineoverridevirtual |
Returns the number of partitions when parallel simulation is active; otherwise it returns 0.
Implements cEnvir.
|
inlineoverridevirtual |
The function underlying cSimulation::getUniqueNumber().
Implements cEnvir.
|
inlineoverridevirtual |
Used by cOsgCanvas to increase the reference count of an osg::Node. Should delegate to node->ref() when OSG support is available.
Implements cEnvir.
|
inlineoverridevirtual |
Used by cOsgCanvas to increase the reference count of an osg::Node. Should delegate to node->unref() when OSG support is available.
Implements cEnvir.
|
inlineoverridevirtual |
May be called from the simulation while actively waiting for some external condition to occur – for example from blocking receive in parallel simulation, or during wait in real-time simulation.
In a graphical user interface, this method may take care of display redraw and handling user interaction (including handling of the Stop button).
Normally returns false. A true value means the user wants to abort waiting (e.g. pushed the Stop button).
Implements cEnvir.
|
inlineoverridevirtual |
Starts an external debugger program and attaches it to this process, if no already attached debugger is detected. The command line to start the debugger can be configured.
The error parameter points to the exception that is the reason a debugger is needed. If there is no error, just a simple request for debugging, it is nullptr.
Returns true if a debugger was already attached, or one could be started and attached successfully. Returns false if a debugger was not already attached and could not be started, or the user chose not to start and attach one.
Implements cEnvir.