OMNeT++ Simulation Library
6.0.3
|
#include <cscheduler.h>
Abstract class to encapsulate event scheduling.
The central method is takeNextEvent().
To switch to your own scheduler class (reasons you'd like to do that include real-time simulation, hardware-in-the-loop simulation, distributed (federated) simulation, parallel distributed simulation), subclass cScheduler, register your new class with the Register_Class() macro, then add the following to omnetpp.ini
:
[General] scheduler-class = "MyClass"
Public Member Functions | |
cScheduler () | |
virtual | ~cScheduler () |
virtual std::string | str () const override |
virtual void | setSimulation (cSimulation *_sim) |
cSimulation * | getSimulation () const |
virtual void | startRun () |
virtual void | endRun () |
virtual void | executionResumed () |
virtual cEvent * | guessNextEvent ()=0 |
virtual cEvent * | takeNextEvent ()=0 |
virtual void | putBackEvent (cEvent *event)=0 |
Public Member Functions inherited from cObject | |
cObject () | |
cObject (const cObject &other)=default | |
virtual | ~cObject () |
virtual const char * | getClassName () const |
virtual const char * | getName () const |
bool | isName (const char *s) const |
virtual const char * | getFullName () const |
virtual std::string | getFullPath () const |
virtual std::string | getClassAndFullName () const |
virtual std::string | getClassAndFullPath () const |
const cObject * | getThisPtr () const |
virtual std::ostream & | printOn (std::ostream &os) const |
virtual cObject * | dup () const |
virtual void | parsimPack (cCommBuffer *buffer) const |
virtual void | parsimUnpack (cCommBuffer *buffer) |
virtual cObject * | getOwner () const |
virtual bool | isOwnedObject () const |
virtual bool | isSoftOwner () const |
virtual void | forEachChild (cVisitor *v) |
cObject * | findObject (const char *name, bool deep=true) |
virtual cClassDescriptor * | getDescriptor () const |
void | copyNotSupported () const |
Public Member Functions inherited from cISimulationLifecycleListener | |
virtual | ~cISimulationLifecycleListener () |
virtual void | listenerAdded () |
virtual void | listenerRemoved () |
Protected Member Functions | |
virtual void | lifecycleEvent (SimulationLifecycleEventType eventType, cObject *details) override |
Protected Member Functions inherited from cObject | |
virtual void | take (cOwnedObject *obj) |
virtual void | drop (cOwnedObject *obj) |
void | dropAndDelete (cOwnedObject *obj) |
Additional Inherited Members | |
Static Public Member Functions inherited from cISimulationLifecycleListener | |
static const char * | getSimulationLifecycleEventName (SimulationLifecycleEventType eventType) |
|
inline |
Constructor.
|
inlinevirtual |
Destructor.
|
overrideprotectedvirtual |
A cISimulationLifecycleListener method. Delegates to startRun(), endRun() and executionResumed(); override if needed.
Implements cISimulationLifecycleListener.
|
overridevirtual |
Return a short description. This string will be displayed in Qtenv as scheduler information. Returning an empty string means "default scheduler", and is reserved for cSequentialScheduler.
Reimplemented from cObject.
Reimplemented in cRealTimeScheduler, and cSequentialScheduler.
|
virtual |
Pass cSimulation object to scheduler.
|
inline |
Returns the simulation the scheduler belongs to.
|
inlinevirtual |
Called at the beginning of a simulation run.
Reimplemented in cRealTimeScheduler.
|
inlinevirtual |
Called at the end of a simulation run.
|
inlinevirtual |
Called every time the user hits the Run button in Qtenv. Real-time schedulers (e.g. cRealTimeScheduler) may make use of this callback to pin current simulation time to current wall clock time.
Reimplemented in cRealTimeScheduler.
|
pure virtual |
Return the likely next event in the simulation. This method is for UI purposes, it does not play any role in the simulation. A basic implementation would just return a pointer to the first event in the FES, which is accurate for sequential simulation; with parallel, distributed or real-time simulation there might be other events coming from other processes with a yet smaller timestamp.
This method should not have side effects, except for discarding stale events from the FES.
Implemented in cRealTimeScheduler, and cSequentialScheduler.
|
pure virtual |
Return the next event to be processed. Normally (with sequential execution), it just returns the first event in the FES. With parallel and/or real-time simulation, it is also the scheduler's task to synchronize with real time and/or with other partitions.
If there's no more event, it throws cTerminationException.
A nullptr return value means that there's no error but execution was stopped by the user (e.g. with STOP button on the GUI) while takeNextEvent() was waiting for external synchronization.
Implemented in cRealTimeScheduler, and cSequentialScheduler.
|
pure virtual |
Undo for takeNextEvent(), approximately: if an event was obtained from takeNextEvent() but was not yet processed, it is possible to temporarily put it back to the FES.
The scheduler class must guarantee that removing the event via takeNextEvent() again does NOT repeat the side effects of the first takeNextEvent()! That is, the sequence
e = takeNextEvent(); putBackEvent(e); e = takeNextEvent();
should be equivalent to a single takeNextEvent() call.
Implemented in cRealTimeScheduler, and cSequentialScheduler.