OMNeT++ Simulation Library  5.6.1
cEvent Class Referenceabstract

#include <cevent.h>

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.

Inheritance diagram for cEvent:
cOwnedObject cNamedObject cObject cMessage cPacket

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 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
 
virtual bool isSoftOwner () const
 
- 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)
 
virtual ~cObject ()
 
virtual const char * getClassName () const
 
bool isName (const char *s) const
 
virtual const char * getFullName () const
 
virtual std::string getFullPath () const
 
const cObjectgetThisPtr () const
 
virtual _OPPDEPRECATED std::string info () const
 
virtual _OPPDEPRECATED std::string detailedInfo () const
 
cObjectfindObject (const char *name, bool deep=true)
 
void copyNotSupported () const
 

Additional Inherited Members

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

Constructor & Destructor Documentation

◆ cEvent() [1/2]

cEvent ( const cEvent event)

Copy constructor.

◆ cEvent() [2/2]

cEvent ( const char *  name)
explicit

Constructor.

◆ ~cEvent()

virtual ~cEvent ( )
virtual

Destructor.

Member Function Documentation

◆ operator=()

cEvent& operator= ( const cEvent event)

Assignment operator. Duplication and the assignment operator work all right with cEvent. The name member doesn't get copied; see cNamedObject's operator=() for more details.

◆ 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.

◆ 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)
inline

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.

◆ 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()

◆ isMessage()

virtual bool isMessage ( ) const
inlinevirtual

A fast way (that is, faster than dynamic_cast) to determine whether this event is a cMessage.

◆ 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.

◆ 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.

◆ 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.


The documentation for this class was generated from the following file: