cEvent Class Reference

API: cEvent Class Reference
API
cEvent Class Referenceabstract
Inheritance diagram for cEvent:
[legend]

Public Member Functions

Constructors, destructor, assignment
 cEvent (const cEvent &event)
 cEvent (const char *name)
virtual ~cEvent ()
cEventoperator= (const cEvent &event)
Redefined cObject member functions.
virtual cEventdup () 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 cObjectgetTargetObject () 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 ()
cOwnedObjectoperator= (const cOwnedObject &o)
virtual cObjectgetOwner () 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 ()
cNamedObjectoperator= (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 cObjectgetThisPtr () const
virtual std::ostream & printOn (std::ostream &os) const
virtual bool isSoftOwner () const
cObjectfindObject (const char *name, bool deep=true)
virtual cClassDescriptorgetDescriptor () const
void copyNotSupported () const

Additional Inherited Members

Static Public Member Functions inherited from cOwnedObject
static long getTotalObjectCount ()
static long getLiveObjectCount ()
static void resetObjectCounters ()
static cSoftOwnergetOwningContext ()
Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
virtual void drop (cOwnedObject *obj)
void dropAndDelete (cOwnedObject *obj)

Description

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.

Constructor & Destructor Documentation

◆ cEvent() [1/2]

cEvent ( const cEvent & event)
inline

Copy constructor.

References cEvent(), and operator=().

Referenced by cEvent(), dup(), operator=(), and shouldPrecede().

◆ cEvent() [2/2]

cEvent ( const char * name)
inlineexplicit

Constructor.

◆ ~cEvent()

virtual ~cEvent ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ operator=()

cEvent & operator= ( const cEvent & event)

Assignment operator. The name member is not copied; see cNamedObject::operator=() for details.

References cEvent().

Referenced by cEvent().

◆ dup()

virtual cEvent * dup ( ) const
overridepure virtual

Redefined to override return type. See cObject for more details.

Reimplemented from cObject.

Implemented in cMessage, and cPacket.

References cEvent().

◆ str()

virtual std::string str ( ) const
overridevirtual

Produces a one-line description of the object's contents. See cObject for more details.

Reimplemented from cObject.

Reimplemented in cMessage, and cPacket.

◆ forEachChild()

virtual void forEachChild ( cVisitor * v)
overridevirtual

Calls v->visit(this) for each contained object. See cObject for more details.

Reimplemented from cObject.

Reimplemented in cMessage, and cPacket.

◆ parsimPack()

virtual void parsimPack ( cCommBuffer * buffer) const
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.

Reimplemented in cMessage, and cPacket.

◆ parsimUnpack()

virtual void parsimUnpack ( cCommBuffer * buffer)
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.

Reimplemented in cMessage, and cPacket.

◆ setSchedulingPriority()

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.

◆ getSchedulingPriority()

short getSchedulingPriority ( ) const
inline

Returns the scheduling priority of this event.

◆ isScheduled()

bool isScheduled ( ) const
inline

Returns true if this event is in the future events set (FES).

◆ getArrivalTime()

simtime_t_cref getArrivalTime ( ) const
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.

◆ getTargetObject()

virtual cObject * getTargetObject ( ) const
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.

See also
cMessage::getArrivalModule()

Implemented in cMessage.

◆ isMessage()

virtual bool isMessage ( ) const
inlinevirtual

Returns true if the object is a subclass of cMessage. This method is a more efficient alternative of dynamic_cast.

Reimplemented in cMessage.

◆ isPacket()

virtual bool isPacket ( ) const
inlinevirtual

Return true if the object is a subclass of cPacket. This method is a more efficient alternative of dynamic_cast.

Reimplemented in cMessage, and cPacket.

◆ isStale()

virtual bool isStale ( )
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.

◆ shouldPrecede()

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.

References cEvent().

◆ execute()

virtual void execute ( )
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.