OMNeT++ Simulation Library
6.0.3
|
#include <clifecyclelistener.h>
A callback interface for receiving notifications at various stages simulations, including setting up, running, and tearing down..
Listeners can be added to cEnvir with its addLifecycleListener() method, and removed with removeLifecycleListener().
Simulation lifecycle listeners are mainly intended for use by plug-in classes that extend the simulator's functionality: schedulers, output vector/scalar managers, parallel simulation algorithms and so on. The lifecycle of a such plug-in class is managed by OMNeT++, so one can use their constructor to add the listener to cEnvir, and the destructor to remove it. (The latter is done automatically.)
Notifications always refer to the active simulation (see cSimulation::getActiveSimulation()).
For standalone listeners that have no other way to be invoked, one can use the EXECUTE_ON_STARTUP(code)
macro to automatically add a listener when the program starts:
EXECUTE_ON_STARTUP(getEnvir()->addLifecycleListener(new MyListener()));
Note that listeners will not be deleted automatically when the program exits. To delete a listener on shutdown, add delete this;
into the listenerRemoved() method.
Public Member Functions | |
virtual | ~cISimulationLifecycleListener () |
virtual void | lifecycleEvent (SimulationLifecycleEventType eventType, cObject *details)=0 |
virtual void | listenerAdded () |
virtual void | listenerRemoved () |
Static Public Member Functions | |
static const char * | getSimulationLifecycleEventName (SimulationLifecycleEventType eventType) |
|
virtual |
The destructor removes the listener from cEnvir if it is still added.
|
pure virtual |
The main listener method, called on simulation lifecycle events.
Implemented in cISnapshotManager, cIOutputScalarManager, cIOutputVectorManager, and cScheduler.
|
inlinevirtual |
Fired after this listener was added to cEnvir, via addLifecycleListener().
|
inlinevirtual |
Fired after this listener was removed from cEnvir, via removeLifecycleListener(). It is OK for the listener to delete itself in the body of this method (delete this
).
|
static |
Returns the string representation of the simulation lifecycle event type.