Represents an event in the discrete event simulator.
When events are scheduled, they are inserted into the future events set (FES) where they are (conceptually) stored in timestamp (="arrival time") order. Events are removed from the FES one by one, and processed by invoking their execute() methods. execute() should be overridden in subclasses to carry out the actions associated with the event.
If several events have identical timestamp values (arrival times), further fields decide their ordering: first, scheduling priority and then, insertion order.
Pure event objects (cEvent) are normally of little interest to the user. Instead, one should use messages and packets (cMessage, cPacket). They are subclassed from cEvent, and their execute() methods automatically delivers the message/packet to the target module.
Public Member Functions | |
Constructors, destructor, assignment | |
cEvent (const cEvent &event) | |
cEvent (const char *name) | |
virtual | ~cEvent () |
cEvent & | operator= (const cEvent &event) |
Redefined cObject member functions. | |
virtual cEvent * | dup () const override=0 |
virtual std::string | str () const override |
virtual void | forEachChild (cVisitor *v) override |
virtual void | parsimPack (cCommBuffer *buffer) const override |
virtual void | parsimUnpack (cCommBuffer *buffer) override |
Event attributes. | |
void | setSchedulingPriority (short p) |
short | getSchedulingPriority () const |
Arrival information. | |
bool | isScheduled () const |
simtime_t_cref | getArrivalTime () const |
virtual cObject * | getTargetObject () const =0 |
Methods to be used by the simulation kernel and the scheduler. | |
virtual bool | isMessage () const |
virtual bool | isPacket () const |
virtual bool | isStale () |
bool | shouldPrecede (const cEvent *event) const |
virtual void | execute ()=0 |
Public Member Functions inherited from cOwnedObject | |
cOwnedObject () | |
cOwnedObject (const char *name, bool namepooling=true) | |
cOwnedObject (const cOwnedObject &obj) | |
virtual | ~cOwnedObject () |
cOwnedObject & | operator= (const cOwnedObject &o) |
virtual cObject * | getOwner () const override |
virtual bool | isOwnedObject () const override |
Public Member Functions inherited from cNamedObject | |
cNamedObject () | |
cNamedObject (const char *name, bool namepooling=true) | |
cNamedObject (const cNamedObject &obj) | |
virtual | ~cNamedObject () |
cNamedObject & | operator= (const cNamedObject &o) |
virtual void | setName (const char *s) |
virtual const char * | getName () const override |
virtual void | setNamePooling (bool b) |
virtual bool | getNamePooling () |
Public Member Functions inherited from cObject | |
cObject () | |
cObject (const cObject &other)=default | |
virtual | ~cObject () |
virtual const char * | getClassName () 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 bool | isSoftOwner () const |
cObject * | findObject (const char *name, bool deep=true) |
virtual cClassDescriptor * | getDescriptor () const |
void | copyNotSupported () const |
Additional Inherited Members | |
Static Public Member Functions inherited from cOwnedObject | |
static long | getTotalObjectCount () |
static long | getLiveObjectCount () |
static void | resetObjectCounters () |
static cSoftOwner * | getOwningContext () |
Protected Member Functions inherited from cObject | |
virtual void | take (cOwnedObject *obj) |
virtual void | drop (cOwnedObject *obj) |
void | dropAndDelete (cOwnedObject *obj) |
|
inlineexplicit |
Constructor.
|
inlinevirtual |
Destructor.
Assignment operator. The name member is not copied; see cNamedObject::operator=() for details.
|
overridepure virtual |
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
Serializes the object into an MPI send buffer Used by the simulation kernel for parallel execution. See cObject for more details.
Reimplemented from cOwnedObject.
|
overridevirtual |
Deserializes the object from an MPI receive buffer Used by the simulation kernel for parallel execution. See cObject for more details.
Reimplemented from cOwnedObject.
void setSchedulingPriority | ( | short | p | ) |
Sets the scheduling priority of this event. Scheduling priority is used when the simulator inserts messages into the future events set (FES), to order events with identical arrival time values.
The scheduling priority must not be modified while the event is scheduled, i.e. is owned by the FES.
|
inline |
Returns the scheduling priority of this event.
|
inline |
Returns true if this event is in the future events set (FES).
|
inline |
Returns the simulation time this event object has been last scheduled for (regardless whether it is currently scheduled), or zero if the event hasn't been scheduled yet.
|
pure virtual |
Return the object that this event will be delivered to or act upon, or nullptr if there is no such object. For messages and packets this will be the destination module. This method is not used by the simulation kernel for other than informational purposes, e.g. logging.
Implemented in cMessage.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Returns true if this event is stale. An event might go stale while staying in the future events set (FES), for example due to its target object being deleted. Stale events are discarded by the scheduler.
Reimplemented in cMessage.
bool shouldPrecede | ( | const cEvent * | event | ) | const |
Returns true if this event precedes the given one in scheduling order, and false otherwise. Scheduling order is defined by the arrival time first, the scheduling priority second, and the scheduling order (a.k.a FES insertion order) third. Note that this method generally only produces useful results for events inserted in the FES.
|
pure virtual |
This method performs the action associated with the event. When a scheduled event makes it to the front of the FES, it is removed from the FES and its execute() method is invoked. In cMessage, execute() ends up calling the handleMessage() method of the destination module, or switches to the coroutine of its activity() method.
Implemented in cMessage.