OMNeT++ API 6.1
Discrete Event Simulation Library
cSimpleModule Class Reference

Description

Base class for all simple module classes.

cSimpleModule, although packed with simulation-related functionality, does not do anything useful by itself: one has to subclass from it and redefine one or more virtual member functions to make it do useful work. These functions are:

initialize() is called after OMNeT++ created the module. Multi-stage initialization can be achieved by redefining the initialize(int stage) method instead, and also redefining the numInitStages() const method to return the required number of stages.

One has to redefine handleMessage() to contain the internal logic of the module. handleMessage() is called by the simulation kernel when the module receives a message. (An alternative to handleMessage() is activity(), but activity() is not recommended for serious model development because of scalability and debugging issues. activity() also tends to lead to messy module implementations.)

You can send() messages to other modules, or use scheduleAt()+cancelEvent() to implement delays, timers or timeouts. Messages sent or scheduled (but not cancelled) are delivered to modules via handleMessage(), or, when using activity(), via receive().

The finish() functions are called when the simulation terminates successfully. Typical use of finish() is recording statistics collected during simulation.

Inheritance diagram for cSimpleModule:
[legend]

Public Member Functions

Constructors, destructor, assignment.
 cSimpleModule (unsigned stacksize=0)
 
virtual ~cSimpleModule ()
 
Redefined cObject member functions.
virtual std::string str () const override
 
virtual bool isSimple () const override
 
virtual void forEachChild (cVisitor *v) override
 
Redefined cModule functions.
virtual void scheduleStart (simtime_t t) override
 
virtual void arrived (cMessage *msg, cGate *ongate, const SendOptions &options, simtime_t t) override
 
Information about the module.
bool usesActivity () const
 
void setTxUpdateSupport (bool b)
 
bool supportsTxUpdates () const
 
bool isTerminated () const
 
Debugging aids.
virtual void snapshot (cObject *obj=nullptr, const char *label=nullptr)
 
Message sending.
virtual void send (cMessage *msg, int gateid)
 
virtual void send (cMessage *msg, const char *gatename, int gateindex=-1)
 
virtual void send (cMessage *msg, cGate *outputgate)
 
virtual void send (cMessage *msg, const SendOptions &options, int gateid)
 
virtual void send (cMessage *msg, const SendOptions &options, const char *gatename, int gateindex=-1)
 
virtual void send (cMessage *msg, const SendOptions &options, cGate *outputgate)
 
virtual void sendDelayed (cMessage *msg, simtime_t delay, int gateid)
 
virtual void sendDelayed (cMessage *msg, simtime_t delay, const char *gatename, int gateindex=-1)
 
virtual void sendDelayed (cMessage *msg, simtime_t delay, cGate *outputgate)
 
virtual void sendDirect (cMessage *msg, cModule *mod, const char *inputGateName, int gateIndex=-1)
 
virtual void sendDirect (cMessage *msg, cModule *mod, int inputGateId)
 
virtual void sendDirect (cMessage *msg, cGate *inputGate)
 
virtual void sendDirect (cMessage *msg, const SendOptions &options, cModule *mod, const char *inputGateName, int gateIndex=-1)
 
virtual void sendDirect (cMessage *msg, const SendOptions &options, cModule *mod, int inputGateId)
 
virtual void sendDirect (cMessage *msg, const SendOptions &options, cGate *inputGate)
 
virtual void sendDirect (cMessage *msg, simtime_t propagationDelay, simtime_t duration, cModule *mod, const char *inputGateName, int gateIndex=-1)
 
virtual void sendDirect (cMessage *msg, simtime_t propagationDelay, simtime_t duration, cModule *mod, int inputGateId)
 
virtual void sendDirect (cMessage *msg, simtime_t propagationDelay, simtime_t duration, cGate *inputGate)
 
Self-messages.
virtual void scheduleAt (simtime_t t, cMessage *msg)
 
virtual void scheduleAfter (simtime_t delay, cMessage *msg)
 
virtual void rescheduleAt (simtime_t t, cMessage *msg)
 
virtual void rescheduleAfter (simtime_t delay, cMessage *msg)
 
virtual cMessagecancelEvent (cMessage *msg)
 
virtual void cancelAndDelete (cMessage *msg)
 
Receiving messages.

These methods may only be invoked from activity()-based simple modules.

virtual cMessagereceive ()
 
virtual cMessagereceive (simtime_t timeout)
 
Waiting.
virtual void wait (simtime_t time)
 
virtual void waitAndEnqueue (simtime_t time, cQueue *queue)
 
Stopping the module or the simulation.
virtual void endSimulation ()
 
virtual void halt ()
 
virtual void error (const char *format,...) const
 
Coroutine stack info. Useful only if module uses activity().
virtual bool hasStackOverflow () const
 
virtual unsigned getStackSize () const
 
virtual unsigned getStackUsage () const
 
- Public Member Functions inherited from cModule
 cModule ()
 
virtual ~cModule ()
 
virtual void setName (const char *s) override
 
virtual const char * getFullName () const override
 
virtual std::string getFullPath () const override
 
virtual void setIndex (int index)
 
virtual void setNameAndIndex (const char *name, int index=-1)
 
virtual cGateaddGate (const char *gatename, cGate::Type type)
 
virtual void addGateVector (const char *gatename, cGate::Type type, int size)
 
virtual void setGateSize (const char *gatename, int size)
 
virtual cGategetOrCreateFirstUnconnectedGate (const char *gatename, char suffix, bool inside, bool expand)
 
virtual void getOrCreateFirstUnconnectedGatePair (const char *gatename, bool inside, bool expand, cGate *&gatein, cGate *&gateout)
 
virtual void finalizeParameters () override
 
void buildInside ()
 
virtual ComponentKind getComponentKind () const override
 
virtual bool isPlaceholder () const
 
virtual cModulegetParentModule () const override
 
cModuleTypegetModuleType () const
 
virtual cPropertiesgetProperties () const override
 
bool isVector () const
 
int getIndex () const
 
int getVectorSize () const
 
virtual bool hasSubmodules () const
 
virtual bool hasSubmoduleVector (const char *name) const
 
virtual std::vector< std::string > getSubmoduleVectorNames () const
 
virtual int getSubmoduleVectorSize (const char *name) const
 
virtual void addSubmoduleVector (const char *name, int size)
 
virtual void deleteSubmoduleVector (const char *name)
 
virtual void setSubmoduleVectorSize (const char *name, int size)
 
virtual cModuleaddSubmodule (cModuleType *type, const char *name, int index=-1)
 
virtual bool hasSubmodule (const char *name, int index=-1) const
 
virtual int findSubmodule (const char *name, int index=-1) const
 
virtual cModulegetSubmodule (const char *name, int index=-1) const
 
virtual std::vector< std::string > getSubmoduleNames () const
 
virtual bool containsModule (cModule *module) const
 
virtual bool hasGates () const
 
virtual cGategate (const char *gatename, int index=-1)
 
const cGategate (const char *gatename, int index=-1) const
 
virtual cGategateHalf (const char *gatename, cGate::Type type, int index=-1)
 
const cGategateHalf (const char *gatename, cGate::Type type, int index=-1) const
 
virtual bool hasGate (const char *gatename, int index=-1) const
 
virtual int findGate (const char *gatename, int index=-1) const
 
virtual cGategate (int id)
 
const cGategate (int id) const
 
virtual void deleteGate (const char *gatename)
 
virtual std::vector< std::string > getGateNames () const
 
virtual cGate::Type gateType (const char *gatename) const
 
virtual bool hasGateVector (const char *gatename) const
 
virtual bool isGateVector (const char *gatename) const
 
virtual int gateSize (const char *gatename) const
 
virtual int gateBaseId (const char *gatename) const
 
virtual bool checkInternalConnections () const
 
virtual cPargetAncestorPar (const char *parname)
 
virtual cCanvasgetCanvas () const
 
virtual cOsgCanvasgetOsgCanvas () const
 
virtual void setBuiltinAnimationsAllowed (bool enabled)
 
virtual bool getBuiltinAnimationsAllowed () const
 
virtual void callInitialize () override
 
virtual bool callInitialize (int stage) override
 
virtual void callFinish () override
 
virtual void deleteModule ()
 
virtual void changeParentTo (cModule *mod)
 
- Public Member Functions inherited from cComponent
 cComponent (const char *name=nullptr)
 
virtual ~cComponent ()
 
const cComponentgetThisPtr () const
 
virtual void setDisplayName (const char *name)
 
virtual const char * getDisplayName () const
 
virtual cComponentTypegetComponentType () const
 
cSimulationgetSimulation () const
 
int getId () const
 
virtual const char * getNedTypeName () const
 
virtual std::string getNedTypeAndFullName () const
 
virtual std::string getNedTypeAndFullPath () const
 
bool isModule () const
 
bool isChannel () const
 
virtual cModulegetSystemModule () const
 
virtual cModulegetModuleByPath (const char *path) const
 
virtual cModulefindModuleByPath (const char *path) const
 
virtual int getNumParams () const
 
virtual cParpar (int k)
 
const cParpar (int k) const
 
virtual cParpar (const char *parname)
 
const cParpar (const char *parname) const
 
virtual int findPar (const char *parname) const
 
bool hasPar (const char *s) const
 
virtual cRNGgetRNG (int k) const
 
virtual uint32_t intrand (uint32_t r, int rng=0) const
 
virtual double dblrand (int rng=0) const
 
virtual double uniform (double a, double b, int rng=0) const
 
virtual SimTime uniform (SimTime a, SimTime b, int rng=0) const
 
virtual double exponential (double mean, int rng=0) const
 
virtual SimTime exponential (SimTime mean, int rng=0) const
 
virtual double normal (double mean, double stddev, int rng=0) const
 
virtual SimTime normal (SimTime mean, SimTime stddev, int rng=0) const
 
virtual double truncnormal (double mean, double stddev, int rng=0) const
 
virtual SimTime truncnormal (SimTime mean, SimTime stddev, int rng=0) const
 
virtual double gamma_d (double alpha, double theta, int rng=0) const
 
virtual double beta (double alpha1, double alpha2, int rng=0) const
 
virtual double erlang_k (unsigned int k, double mean, int rng=0) const
 
virtual double chi_square (unsigned int k, int rng=0) const
 
virtual double student_t (unsigned int i, int rng=0) const
 
virtual double cauchy (double a, double b, int rng=0) const
 
virtual double triang (double a, double b, double c, int rng=0) const
 
virtual double lognormal (double m, double w, int rng=0) const
 
virtual double weibull (double a, double b, int rng=0) const
 
virtual double pareto_shifted (double a, double b, double c, int rng=0) const
 
virtual int intuniform (int a, int b, int rng=0) const
 
virtual int intuniformexcl (int a, int b, int rng=0) const
 
virtual int bernoulli (double p, int rng=0) const
 
virtual int binomial (int n, double p, int rng=0) const
 
virtual int geometric (double p, int rng=0) const
 
virtual int negbinomial (int n, double p, int rng=0) const
 
virtual int poisson (double lambda, int rng=0) const
 
virtual void subscribe (simsignal_t signalID, cIListener *listener)
 
virtual void subscribe (const char *signalName, cIListener *listener)
 
virtual void unsubscribe (simsignal_t signalID, cIListener *listener)
 
virtual void unsubscribe (const char *signalName, cIListener *listener)
 
virtual bool isSubscribed (simsignal_t signalID, cIListener *listener) const
 
virtual bool isSubscribed (const char *signalName, cIListener *listener) const
 
virtual std::vector< simsignal_tgetLocalListenedSignals () const
 
virtual std::vector< cIListener * > getLocalSignalListeners (simsignal_t signalID) const
 
virtual bool hasGUI () const
 
virtual cDisplayStringgetDisplayString () const
 
virtual void setDisplayString (const char *dispstr)
 
virtual void bubble (const char *text) const
 
virtual std::string resolveResourcePath (const char *fileName) const
 
virtual void recordScalar (const char *name, double value, const char *unit=nullptr)
 
virtual void recordScalar (const char *name, SimTime value, const char *unit=nullptr)
 
virtual void recordStatistic (cStatistic *stats, const char *unit=nullptr)
 
virtual void recordStatistic (const char *name, cStatistic *stats, const char *unit=nullptr)
 
virtual void emit (simsignal_t signalID, bool b, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, double d, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, const SimTime &t, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, const char *s, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, cObject *obj, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, const cObject *obj, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, char c, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, unsigned char c, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, short i, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, unsigned short i, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, int i, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, unsigned int i, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, long i, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, unsigned long i, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, long long i, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, unsigned long long i, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, float f, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, long double d, cObject *details=nullptr)
 
bool mayHaveListeners (simsignal_t signalID) const
 
bool hasListeners (simsignal_t signalID) const
 
- Public Member Functions inherited from cSoftOwner
 cSoftOwner (const char *name=nullptr, bool namepooling=true)
 
virtual ~cSoftOwner ()
 
virtual bool isSoftOwner () const override
 
int getNumOwnedObjects () const
 
cOwnedObjectgetOwnedObject (int k)
 
- Public Member Functions inherited from cNoncopyableOwnedObject
 cNoncopyableOwnedObject (const char *name=nullptr, bool namepooling=true)
 
virtual cNoncopyableOwnedObjectdup () const override
 
- 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 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 std::string getClassAndFullName () const
 
virtual std::string getClassAndFullPath () const
 
const cObjectgetThisPtr () const
 
virtual std::ostream & printOn (std::ostream &os) const
 
cObjectfindObject (const char *name, bool deep=true)
 
virtual cClassDescriptorgetDescriptor () const
 
void copyNotSupported () const
 

Protected Member Functions

Hooks for defining module behavior.

Exactly one of activity() and handleMessage() must be redefined by the user to add functionality to the simple module. See the manual for detailed guidance on how use to these two methods.

These methods are made protected because they shouldn't be called directly from outside.

virtual void activity ()
 
virtual void handleMessage (cMessage *msg)
 
- Protected Member Functions inherited from cComponent
virtual void initialize (int stage)
 
virtual int numInitStages () const
 
virtual void initialize ()
 
virtual void finish ()
 
virtual void handleParameterChange (const char *parname)
 
virtual void refreshDisplay () const
 
virtual void preDelete (cComponent *root)
 
- Protected Member Functions inherited from cSoftOwner
virtual void take (cOwnedObject *obj) override
 
virtual void drop (cOwnedObject *obj) override
 
- Protected Member Functions inherited from cObject
void dropAndDelete (cOwnedObject *obj)
 

Additional Inherited Members

- Static Public Member Functions inherited from cComponent
static simsignal_t registerSignal (const char *name)
 
static const char * getSignalName (simsignal_t signalID)
 
- Static Public Member Functions inherited from cOwnedObject
static long getTotalObjectCount ()
 
static long getLiveObjectCount ()
 
static void resetObjectCounters ()
 
static cSoftOwnergetOwningContext ()
 

Constructor & Destructor Documentation

◆ cSimpleModule()

cSimpleModule ( unsigned  stacksize = 0)

Constructor. Note that module objects should not be created directly, only via their cModuleType objects. See cModule constructor for more info. The stacksize parameter should only be used with simple modules using activity().

◆ ~cSimpleModule()

virtual ~cSimpleModule ( )
virtual

Destructor. Note: it is not allowed delete modules directly, only via the deleteModule() method.

Member Function Documentation

◆ activity()

virtual void activity ( )
protectedvirtual

Should be redefined to contain the module activity function. For several good reasons, you should prefer handleMessage() to activity(). This default implementation issues an error message (throws cRuntimeError).

◆ handleMessage()

virtual void handleMessage ( cMessage msg)
protectedvirtual

Should be redefined to contain the module's message handling function. This default implementation issues an error message (throws cRuntimeError).

◆ str()

virtual std::string str ( ) const
overridevirtual

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

Reimplemented from cModule.

◆ isSimple()

virtual bool isSimple ( ) const
overridevirtual

Returns true.

Reimplemented from cModule.

◆ forEachChild()

virtual void forEachChild ( cVisitor v)
overridevirtual

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

Reimplemented from cModule.

◆ scheduleStart()

virtual void scheduleStart ( simtime_t  t)
overridevirtual

Creates a starting message for the module.

Reimplemented from cModule.

◆ arrived()

virtual void arrived ( cMessage msg,
cGate ongate,
const SendOptions options,
simtime_t  t 
)
overridevirtual

This method is invoked on the module at the end of the connection path, as part of the send()/sendDirect() protocol. This implementation inserts the message into the FES after some processing.

Reimplemented from cModule.

◆ usesActivity()

bool usesActivity ( ) const
inline

Returns the event handling scheme: activity() or handleMessage().

◆ setTxUpdateSupport()

void setTxUpdateSupport ( bool  b)
inline

Calling this method with the argument of true indicates that this module is prepared to receive transmission updates, and can handle them properly.

This method (and the underlying flag) exists to reduce the chance of unprepared modules receiving transmission updates and interpreting them as independent packets, leading to subtle errors in the simulation. If this flag is not set on a module, then sending a transmission update to it will result in a runtime error.

Modules that set the flag are supposed to check whether a received packet is a transmission update by calling cPacket::isUpdate(), and act accordingly.

See also
supportsTxUpdates(), cPacket::isUpdate(), SendOptions::updateTx()

◆ supportsTxUpdates()

bool supportsTxUpdates ( ) const
inline

Returns true if this module is prepared to receive transmission updates.

See also
setTxUpdateSupport(), cPacket::isUpdate(), SendOptions::updateTx()

◆ isTerminated()

bool isTerminated ( ) const
inline

Returns true if the module has already terminated, by having called end() or returning from the activity() method.

◆ snapshot()

virtual void snapshot ( cObject obj = nullptr,
const char *  label = nullptr 
)
virtual

To be called from module functions. Outputs textual information about all objects of the simulation (including the objects created in module functions by the user!) into the snapshot file. The output is detailed enough to be used for debugging the simulation: by regularly calling snapshot(), one can trace how the values of variables, objects changed over the simulation. The arguments: label is a string that will appear in the output file; obj is the object whose inside is of interest. By default, the whole simulation (all modules etc) will be written out.

Qtenv also supports making snapshots interactively.

See also class cWatch and the WATCH() macro.

◆ send() [1/6]

virtual void send ( cMessage msg,
int  gateid 
)
inlinevirtual

Sends a message through the gate given with its ID.

References cSimpleModule::send().

Referenced by cSimpleModule::send().

◆ send() [2/6]

virtual void send ( cMessage msg,
const char *  gatename,
int  gateindex = -1 
)
inlinevirtual

Sends a message through the gate given with its name and index. The index argument is only required if the gate is part of a gate vector.

References cSimpleModule::send().

Referenced by cSimpleModule::send().

◆ send() [3/6]

virtual void send ( cMessage msg,
cGate outputgate 
)
inlinevirtual

Sends a message through the gate given with its pointer.

References cSimpleModule::send().

Referenced by cSimpleModule::send().

◆ send() [4/6]

virtual void send ( cMessage msg,
const SendOptions options,
int  gateid 
)
inlinevirtual

Sends a message with the given options through the gate given with its ID.

References cSimpleModule::send().

Referenced by cSimpleModule::send().

◆ send() [5/6]

virtual void send ( cMessage msg,
const SendOptions options,
const char *  gatename,
int  gateindex = -1 
)
inlinevirtual

Sends a message with the given options through the gate given with its name and index. The index argument is only required if the gate is part of a gate vector.

References cSimpleModule::send().

Referenced by cSimpleModule::send().

◆ send() [6/6]

virtual void send ( cMessage msg,
const SendOptions options,
cGate outputgate 
)
virtual

Sends a message with the given options through the gate given with its pointer.

◆ sendDelayed() [1/3]

virtual void sendDelayed ( cMessage msg,
simtime_t  delay,
int  gateid 
)
inlinevirtual

Utility function, equivalent to send(msg, SendOptions().after(delay), gateid).

◆ sendDelayed() [2/3]

virtual void sendDelayed ( cMessage msg,
simtime_t  delay,
const char *  gatename,
int  gateindex = -1 
)
inlinevirtual

Utility function, equivalent to send(msg, SendOptions().after(delay), gatename, gateindex).

◆ sendDelayed() [3/3]

virtual void sendDelayed ( cMessage msg,
simtime_t  delay,
cGate outputgate 
)
inlinevirtual

Utility function, equivalent to send(msg, SendOptions().after(delay), outputgate).

◆ sendDirect() [1/9]

virtual void sendDirect ( cMessage msg,
cModule mod,
const char *  inputGateName,
int  gateIndex = -1 
)
inlinevirtual

Sends a message directly to another module, with zero propagation delay and duration. See sendDirect(cMessage *, const SendOptions&, cGate *) for a more detailed description.

References cSimpleModule::sendDirect().

Referenced by cSimpleModule::sendDirect().

◆ sendDirect() [2/9]

virtual void sendDirect ( cMessage msg,
cModule mod,
int  inputGateId 
)
inlinevirtual

Sends a message directly to another module, with zero propagation delay and duration. See sendDirect(cMessage *, const SendOptions&, cGate *) for a more detailed description.

References cSimpleModule::sendDirect().

Referenced by cSimpleModule::sendDirect().

◆ sendDirect() [3/9]

virtual void sendDirect ( cMessage msg,
cGate inputGate 
)
inlinevirtual

Sends a message directly to another module, with zero propagation delay and duration. See sendDirect(cMessage *, const SendOptions&, cGate *) for a more detailed description.

References cSimpleModule::sendDirect().

Referenced by cSimpleModule::sendDirect().

◆ sendDirect() [4/9]

virtual void sendDirect ( cMessage msg,
const SendOptions options,
cModule mod,
const char *  inputGateName,
int  gateIndex = -1 
)
inlinevirtual

Sends a message directly to another module, with the given options. See sendDirect(cMessage *, const SendOptions&, cGate *) for a more detailed description.

References cSimpleModule::sendDirect().

Referenced by cSimpleModule::sendDirect().

◆ sendDirect() [5/9]

virtual void sendDirect ( cMessage msg,
const SendOptions options,
cModule mod,
int  inputGateId 
)
inlinevirtual

Sends a message directly to another module, with the given options. See sendDirect(cMessage *, const SendOptions&, cGate *) for a more detailed description.

References cSimpleModule::sendDirect().

Referenced by cSimpleModule::sendDirect().

◆ sendDirect() [6/9]

virtual void sendDirect ( cMessage msg,
const SendOptions options,
cGate inputGate 
)
virtual

Send a message directly to another module, with the given options.

If the target gate is further connected (i.e. getNextGate()!=nullptr), the message will follow the connection path that starts at that gate. Notably, when sending to an input gate of a compound module, the message will follow the connections inside the compound module.

It is permitted to send to an output gate, which will also cause the message to follow the connections starting at that gate. This can be useful, for example, when several submodules are sending to a single output gate of their parent module.

It is not permitted to send to a gate of a compound module which is not further connected (i.e. getNextGate()==nullptr), as this would cause the message to arrive at a compound module.

Also, it is not permitted to send to a gate which is otherwise connected i.e. where getPreviousGate()!=nullptr. This means that modules MUST have dedicated gates for receiving via sendDirect(). You cannot have a gate which receives messages via both connections and sendDirect().

◆ sendDirect() [7/9]

virtual void sendDirect ( cMessage msg,
simtime_t  propagationDelay,
simtime_t  duration,
cModule mod,
const char *  inputGateName,
int  gateIndex = -1 
)
inlinevirtual

Utility function, roughly equivalent to sendDirect(msg, SendOptions().propagationDelay(delay).duration(duration), mod, inputGateName, gateIndex).

References cSimpleModule::sendDirect().

Referenced by cSimpleModule::sendDirect().

◆ sendDirect() [8/9]

virtual void sendDirect ( cMessage msg,
simtime_t  propagationDelay,
simtime_t  duration,
cModule mod,
int  inputGateId 
)
inlinevirtual

Utility function, roughly equivalent to sendDirect(msg, SendOptions().propagationDelay(delay).duration(duration), mod, inputGateId).

References cSimpleModule::sendDirect().

Referenced by cSimpleModule::sendDirect().

◆ sendDirect() [9/9]

virtual void sendDirect ( cMessage msg,
simtime_t  propagationDelay,
simtime_t  duration,
cGate inputGate 
)
inlinevirtual

Utility function, roughly equivalent to sendDirect(msg, SendOptions().propagationDelay(delay).duration(duration), inputGate).

References cSimpleModule::sendDirect().

Referenced by cSimpleModule::sendDirect().

◆ scheduleAt()

virtual void scheduleAt ( simtime_t  t,
cMessage msg 
)
virtual

Schedules a self-message. It will be delivered back to the module via receive() or handleMessage() at simulation time t. This method is the way you can implement timers or timeouts. Timers can also be cancelled via cancelEvent() (See below.)

When the message is delivered at the module, you can call msg->isSelfMessage() to tell it apart from messages arriving from other modules. msg->getKind() can be used to further classify it, or of you need to manage an unbounded number of timers, you can set msg->getContextPointer() before scheduling to point to the data structure the message belongs to – this way you can avoid having to search through lists or other data structures to find out where a just-arrived self-message belongs.

cancelEvent() can be used to cancel the self-message before it arrives. This is useful for implementing timeouts: if the event occurs "in time" (before timeout), the scheduled self-message can be cancelled.

Given a cMessage pointer, you can check whether it is currently scheduled by calling msg->isScheduled(). If it is scheduled, you cannot schedule it again without calling cancelEvent() first. However, after the message was delivered to the module or cancelled, you can schedule it again – so you can reuse the same message object for timeouts over and over during the whole simulation.

See also
scheduleAfter()

◆ scheduleAfter()

virtual void scheduleAfter ( simtime_t  delay,
cMessage msg 
)
virtual

Schedules a self-message for the given time delta after the current simulation time. This method is equivalent to scheduleAt(simTime()+delay, msg); See scheduleAt() for more information.

See also
scheduleAt()

◆ rescheduleAt()

virtual void rescheduleAt ( simtime_t  t,
cMessage msg 
)
virtual

Equivalent to scheduleAt(simtime_t t, cMessage *msg), except that if the message is currently scheduled, the method cancels it before scheduling it again.

See also
scheduleAt(), cancelEvent(), cMessage::isScheduled()

◆ rescheduleAfter()

virtual void rescheduleAfter ( simtime_t  delay,
cMessage msg 
)
virtual

Equivalent to scheduleAfter(simtime_t t, cMessage *msg), except that if the message is currently scheduled, the method cancels it before scheduling it again.

See also
scheduleAfter(), cancelEvent(), cMessage::isScheduled()

◆ cancelEvent()

virtual cMessage* cancelEvent ( cMessage msg)
virtual

Removes the given message from the future events. The message needs to have been sent using the scheduleAt() function. This function can be used to cancel a timer implemented with scheduleAt(). If the message is not currently scheduled, nothing happens.

◆ cancelAndDelete()

virtual void cancelAndDelete ( cMessage msg)
virtual

Invokes cancelEvent() on the message (in case it is scheduled), then deletes it. nullptr is also accepted, then the method does nothing. This method is especially useful in simple module destructors, to dispose of self-messages that the module has allocated.

◆ receive() [1/2]

virtual cMessage* receive ( )
virtual

Remove the next message from the event queue and return a pointer to it.

◆ receive() [2/2]

virtual cMessage* receive ( simtime_t  timeout)
virtual

Removes the next message from the event queue and returns a pointer to it. If there is no message in the event queue, the function waits with t timeout until a message will be available. If the timeout expires and there is still no message in the queue, the function returns nullptr.

◆ wait()

virtual void wait ( simtime_t  time)
virtual

Waits for the given interval. (Some other simulators call this functionality hold()). It is intended for use only if you do not expect other messages to arrive at the module during the wait period. To assert this, it throws an exception if a message arrives during the wait.

If you expect to receive messages during the call, you should use waitAndEnqueue() instead.

This function can only be used with activity(), but not with handleMessage().

◆ waitAndEnqueue()

virtual void waitAndEnqueue ( simtime_t  time,
cQueue queue 
)
virtual

Waits for the given interval. The messages received during the wait period are inserted into the queue passed as argument.

This function can only be used with activity(), but not with handleMessage().

◆ endSimulation()

virtual void endSimulation ( )
virtual

Causes the whole simulation to stop. The implementation simply throws a cTerminationException.

◆ halt()

virtual void halt ( )
virtual

May only be invoked from activity()-based simple modules. Execution of the simple module stops in this call, and any further messages sent to module will cause a runtime error.

◆ error()

virtual void error ( const char *  format,
  ... 
) const
virtual

Equivalent to throw cRuntimeError(same argument list).

◆ hasStackOverflow()

virtual bool hasStackOverflow ( ) const
virtual

Returns true if there was a stack overflow during execution of the coroutine. (Not implemented for every coroutine package - see cCoroutine documentation for more info.) If the module uses handleMessage(), this method always returns false.

See also
cCoroutine

◆ getStackSize()

virtual unsigned getStackSize ( ) const
virtual

Returns the stack size of the coroutine. If the module uses handleMessage(), this method always returns 0.

◆ getStackUsage()

virtual unsigned getStackUsage ( ) const
virtual

Returns the amount of stack actually used by the coroutine. (Not implemented for every coroutine package - see cCoroutine documentation for more info.) If the module uses handleMessage(), this method always returns 0.

See also
cCoroutine

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