OMNeT++ Simulation Library  5.6.1
cModule Class Reference

#include <cmodule.h>

Description

This class represents modules in the simulation.

cModule can be used directly for compound modules. Simple module classes need to be subclassed from cSimpleModule, a class that adds more functionality to cModule.

For navigating the module tree, see: getParentModule(), getSubmodule(), cModule::SubmoduleIterator, cModule::getModuleByPath(), cSimulation::getModuleByPath().

Inheritance diagram for cModule:
cComponent cDefaultList cNoncopyableOwnedObject cOwnedObject noncopyable cNamedObject cObject cSimpleModule

Classes

class  ChannelIterator
 Walks along the channels inside a module, that is, the channels among the module and its submodules. More...
 
class  GateIterator
 Iterates through the gates of a module. More...
 
class  SubmoduleIterator
 Iterates through the submodules of a compound module. More...
 

Public Member Functions

Constructors, destructor, assignment.
 cModule ()
 
virtual ~cModule ()
 
Redefined cObject member functions.
virtual void forEachChild (cVisitor *v) override
 
virtual void setName (const char *s) override
 
virtual const char * getFullName () const override
 
virtual std::string getFullPath () const override
 
virtual std::string str () const override
 
Setting up the module.
virtual cGateaddGate (const char *gatename, cGate::Type type, bool isvector=false)
 
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 ()
 
Information about the module itself.
virtual bool isSimple () const
 
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
 
_OPPDEPRECATED int size () const
 
Submodule access.
virtual bool hasSubmodules () const
 
virtual int findSubmodule (const char *name, int index=-1) const
 
virtual cModulegetSubmodule (const char *name, int index=-1) const
 
virtual cModulegetModuleByPath (const char *path) const
 
virtual bool containsModule (cModule *module) const
 
Gates.
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< const char * > getGateNames () const
 
virtual cGate::Type gateType (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 void arrived (cMessage *msg, cGate *ongate, simtime_t t)
 
Utilities.
virtual cPargetAncestorPar (const char *parname)
 
virtual cCanvasgetCanvas () const
 
virtual cOsgCanvasgetOsgCanvas () const
 
virtual void setBuiltinAnimationsAllowed (bool enabled)
 
virtual bool getBuiltinAnimationsAllowed () const
 
Public methods for invoking initialize()/finish(), redefined from cComponent.

initialize(), numInitStages(), and finish() are themselves also declared in cComponent, and can be redefined in simple modules by the user to perform initialization and finalization (result recording, etc) tasks.

virtual void callInitialize () override
 
virtual bool callInitialize (int stage) override
 
virtual void callFinish () override
 
Dynamic module creation.
virtual void scheduleStart (simtime_t t)
 
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 cComponentTypegetComponentType () const
 
cSimulationgetSimulation () const
 
int getId () const
 
virtual const char * getNedTypeName () const
 
bool isModule () const
 
bool isChannel () const
 
virtual cModulegetSystemModule () 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 unsigned long intrand (long 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, long l, cObject *details=nullptr)
 
virtual void emit (simsignal_t signalID, unsigned long l, 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, 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 cDefaultList
 cDefaultList (const char *name=nullptr)
 
virtual ~cDefaultList ()
 
virtual bool isSoftOwner () const override
 
virtual void parsimPack (cCommBuffer *buffer) const override
 
virtual void parsimUnpack (cCommBuffer *buffer) override
 
bool getPerformFinalGC () const
 
virtual void setPerformFinalGC (bool b)
 
int defaultListSize () const
 
cOwnedObjectdefaultListGet (int k)
 
bool defaultListContains (cOwnedObject *obj) const
 
- 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)
 
virtual ~cObject ()
 
virtual const char * getClassName () const
 
bool isName (const char *s) 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 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 cDefaultListgetDefaultOwner ()
 
- 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
 
- Protected Member Functions inherited from cDefaultList
virtual void take (cOwnedObject *obj) override
 
virtual void drop (cOwnedObject *obj) override
 
- Protected Member Functions inherited from cObject
void dropAndDelete (cOwnedObject *obj)
 

Constructor & Destructor Documentation

◆ cModule()

cModule ( )

Constructor. Note that module objects should not be created directly, only via their cModuleType objects. cModuleType::create() will do all housekeeping tasks associated with module creation (assigning an ID to the module, inserting it into the global simulation object (see cSimulation), etc.).

◆ ~cModule()

virtual ~cModule ( )
virtual

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

Member Function Documentation

◆ forEachChild()

virtual void forEachChild ( cVisitor v)
overridevirtual

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

Reimplemented from cComponent.

Reimplemented in cSimpleModule.

◆ setName()

virtual void setName ( const char *  s)
overridevirtual

Sets object's name. Redefined to update the stored fullName string.

Reimplemented from cNamedObject.

◆ getFullName()

virtual const char* getFullName ( ) const
overridevirtual

Returns the full name of the module, which is getName() plus the index in square brackets (e.g. "module[4]"). Redefined to add the index.

Reimplemented from cObject.

◆ getFullPath()

virtual std::string getFullPath ( ) const
overridevirtual

Returns the full path name of the module. Example: "net.node[12].gen". The original getFullPath() was redefined in order to hide the global cSimulation instance from the path name.

Reimplemented from cObject.

◆ str()

virtual std::string str ( ) const
overridevirtual

Overridden to add the module ID.

Reimplemented from cDefaultList.

Reimplemented in cSimpleModule.

◆ addGate()

virtual cGate* addGate ( const char *  gatename,
cGate::Type  type,
bool  isvector = false 
)
virtual

Adds a gate or gate vector to the module. Gate vectors are created with zero size. When the creation of a (non-vector) gate of type cGate::INOUT is requested, actually two gate objects will be created, "gatename$i" and "gatename$o". The specified gatename must not contain a "$i" or "$o" suffix itself.

CAUTION: The return value is only valid when a non-vector INPUT or OUTPUT gate was requested. nullptr gets returned for INOUT gates and gate vectors.

◆ setGateSize()

virtual void setGateSize ( const char *  gatename,
int  size 
)
virtual

Sets gate vector size. The specified gatename must not contain a "$i" or "$o" suffix: it is not possible to set different vector size for the "$i" or "$o" parts of an inout gate. Changing gate vector size is guaranteed NOT to change any gate IDs.

◆ getOrCreateFirstUnconnectedGate()

virtual cGate* getOrCreateFirstUnconnectedGate ( const char *  gatename,
char  suffix,
bool  inside,
bool  expand 
)
virtual

Helper function for implementing NED's "gate++" syntax. Returns the next unconnected gate from an input or output gate vector, or input/output half of an inout vector. When gatename names an inout gate vector, the suffix parameter should be set to 'i' or 'o' to select "gatename$i" or "gatename$o"; otherwise suffix should be zero. The inside parameter selects whether to use isConnectedInside() or isConnectedOutside() to test if the gate is connected. The expand parameter tells whether the gate vector should be expanded if all its gates are used up.

◆ getOrCreateFirstUnconnectedGatePair()

virtual void getOrCreateFirstUnconnectedGatePair ( const char *  gatename,
bool  inside,
bool  expand,
cGate *&  gatein,
cGate *&  gateout 
)
virtual

Helper function to implement NED's "gate++" syntax. This variant accepts inout gates only, and the result is returned in the gatein and gateout parameters. The meaning of the inside and expand parameters is the same as with getOrCreateFirstUnconnectedGate().

◆ finalizeParameters()

virtual void finalizeParameters ( )
overridevirtual

Redefined from cComponent. This method must be called as part of the module creation process, after moduleType->create() and before mod->buildInside(). It finalizes parameter values (e.g. reads the missing ones from omnetpp.ini), and adds gates and gate vectors (whose size may depend on parameter values) to the module.

So the sequence of setting up a module is:

  1. modType->create()
  2. set parameter values
  3. mod->finalizeParameters() – this creates gates too
  4. connect gates (possibly adding new gates via gate++ operations)
  5. mod->buildInside()

The above sequence also explains why finalizeParameters() cannot by merged into either create() or buildInside().

Reimplemented from cComponent.

◆ buildInside()

void buildInside ( )

In compound modules, this method should be called to create submodules and internal connections after module creation.

This method delegates to doBuildInside(), switching the context to this module for the duration of the call (see simulation.setContextModule()).

See also
doBuildInside()

◆ isSimple()

virtual bool isSimple ( ) const
virtual

Returns true if the C++ class of this module is a subclass of cSimpleModule, and false otherwise, i.e. it is equivalent to a dynamic_cast.

In contrast, to check whether this module is a NED compound or simple module (i.e. whether it was declared with the "module" or with the "simple" keyword in NED), use cModuleType::isSimple(): getModuleType()->isSimple().

◆ getComponentKind()

virtual ComponentKind getComponentKind ( ) const
inlineoverridevirtual

Redefined from cComponent to return KIND_MODULE.

Implements cComponent.

◆ isPlaceholder()

virtual bool isPlaceholder ( ) const
inlinevirtual

Returns true if this module is a placeholder module, i.e. represents a remote module in a parallel simulation run.

◆ getParentModule()

virtual cModule* getParentModule ( ) const
overridevirtual

Returns the module containing this module. For the system module, it returns nullptr.

Implements cComponent.

◆ getModuleType()

cModuleType* getModuleType ( ) const
inline

Convenience method: casts the return value of getComponentType() to cModuleType.

◆ getProperties()

virtual cProperties* getProperties ( ) const
overridevirtual

Return the properties for this module. Properties cannot be changed at runtime. Redefined from cComponent.

Implements cComponent.

◆ isVector()

bool isVector ( ) const
inline

Returns true if this module is in a module vector.

◆ getIndex()

int getIndex ( ) const
inline

Returns the index of the module if it is in a module vector, otherwise 0.

◆ getVectorSize()

int getVectorSize ( ) const
inline

Returns the size of the module vector the module is in. For non-vector modules it returns 1.

◆ size()

_OPPDEPRECATED int size ( ) const
inline

Alias for getVectorSize().

◆ hasSubmodules()

virtual bool hasSubmodules ( ) const
inlinevirtual

Returns true if the module has submodules, and false otherwise. To enumerate the submodules use SubmoduleIterator.

◆ findSubmodule()

virtual int findSubmodule ( const char *  name,
int  index = -1 
) const
virtual

Finds a direct submodule with the given name and index, and returns its module ID. If the submodule was not found, returns -1. Index must be specified exactly if the module is member of a module vector.

◆ getSubmodule()

virtual cModule* getSubmodule ( const char *  name,
int  index = -1 
) const
virtual

Finds a direct submodule with the given name and index, and returns its pointer. If the submodule was not found, returns nullptr. Index must be specified exactly if the module is member of a module vector.

◆ getModuleByPath()

virtual cModule* getModuleByPath ( const char *  path) const
virtual

Finds a module in the module tree, given by its absolute or relative path. The path is a string of module names separated by dots; the special module name ^ (caret) stands for the parent module. If the path starts with a dot or caret, it is understood as relative to this module, otherwise it is taken to mean an absolute path. For absolute paths, inclusion of the toplevel module's name in the path is optional. The toplevel module may also be referred to as "<root>". Returns nullptr if the module was not found or the empty string was given as input.

Examples: "" means nullptr. "." means this module; "<root>" means the toplevel module; ".sink" means the sink submodule of this module; ".queue[2].srv" means the srv submodule of the queue[2] submodule; "^.host2" or ".^.host2" means the host2 sibling module; "src" or "<root>.src" means the src submodule of the toplevel module; "Net.src" also means the src submodule of the toplevel module, provided it is called Net.

See also
cSimulation::getModuleByPath()

◆ containsModule()

virtual bool containsModule ( cModule module) const
virtual

Returns true of the given module has this module as an ancestor, and false otherwise.

◆ gate() [1/4]

virtual cGate* gate ( const char *  gatename,
int  index = -1 
)
virtual

Looks up a gate by its name and index. Gate names with the "$i" or "$o" suffix are also accepted. Throws an error if the gate does not exist. The presence of the index parameter decides whether a vector or a scalar gate will be looked for.

◆ gate() [2/4]

const cGate* gate ( const char *  gatename,
int  index = -1 
) const
inline

Looks up a gate by its name and index. Gate names with the "$i" or "$o" suffix are also accepted. Throws an error if the gate does not exist. The presence of the index parameter decides whether a vector or a scalar gate will be looked for.

◆ gateHalf() [1/2]

virtual cGate* gateHalf ( const char *  gatename,
cGate::Type  type,
int  index = -1 
)
virtual

Returns the "$i" or "$o" part of an inout gate, depending on the type parameter. That is, gateHalf("port", cGate::OUTPUT, 3) would return gate "port$o[3]". Throws an error if the gate does not exist. The presence of the index parameter decides whether a vector or a scalar gate will be looked for.

◆ gateHalf() [2/2]

const cGate* gateHalf ( const char *  gatename,
cGate::Type  type,
int  index = -1 
) const
inline

Returns the "$i" or "$o" part of an inout gate, depending on the type parameter. That is, gateHalf("port", cGate::OUTPUT, 3) would return gate "port$o[3]". Throws an error if the gate does not exist. The presence of the index parameter decides whether a vector or a scalar gate will be looked for.

◆ hasGate()

virtual bool hasGate ( const char *  gatename,
int  index = -1 
) const
virtual

Checks if a gate exists. When invoked without index, it returns whether gate "gatename" or "gatename[]" exists (no matter if the gate vector size is currently zero). When invoked with an index, it returns whether the concrete "gatename[index]" gate exists (gatename being a vector gate). Gate names with the "$i" or "$o" suffix are also accepted.

◆ findGate()

virtual int findGate ( const char *  gatename,
int  index = -1 
) const
virtual

Returns the ID of the gate specified by name and index. Inout gates cannot be specified (since they are actually two gate objects, not one), only with a "$i" or "$o" suffix. Returns -1 if the gate does not exist. The presence of the index parameter decides whether a vector or a scalar gate will be looked for.

◆ gate() [3/4]

virtual cGate* gate ( int  id)
virtual

Returns a gate by its ID. It throws an error for invalid (or stale) IDs.

Note: as of OMNeT++ 4.0, gate IDs are no longer small integers and are not suitable for enumerating all gates of a module. Use GateIterator for that purpose.

◆ gate() [4/4]

const cGate* gate ( int  id) const
inline

Returns a gate by its ID. It throws an error for invalid (or stale) IDs.

Note: as of OMNeT++ 4.0, gate IDs are no longer small integers and are not suitable for enumerating all gates of a module. Use GateIterator for that purpose.

References cModule::gate().

Referenced by cModule::gate().

◆ deleteGate()

virtual void deleteGate ( const char *  gatename)
virtual

Deletes a gate, gate pair, or gate vector. Note: individual gates in a gate vector and one side of an inout gate (i.e. "foo$i") cannot be deleted. IDs of deleted gates will not be reused later.

◆ getGateNames()

virtual std::vector<const char *> getGateNames ( ) const
virtual

Returns the names of the module's gates. For gate vectors and inout gates, only the base name is returned (without gate index, "[]" or the "$i"/"$o" suffix). Zero-size gate vectors will also be included.

The strings in the returned array do not need to be deallocated and must not be modified.

See also
gateType(), isGateVector(), gateSize()

◆ gateType()

virtual cGate::Type gateType ( const char *  gatename) const
virtual

Returns the type of the gate (or gate vector) with the given name. Gate names with the "$i" or "$o" suffix are also accepted. Throws an error if there is no such gate or gate vector.

◆ isGateVector()

virtual bool isGateVector ( const char *  gatename) const
virtual

Returns whether the given gate is a gate vector. Gate names with the "$i" or "$o" suffix are also accepted. Throws an error if there is no such gate or gate vector.

◆ gateSize()

virtual int gateSize ( const char *  gatename) const
virtual

Returns the size of the gate vector with the given name. It returns 1 for non-vector gates, and 0 if the gate does not exist or the vector has size 0. (Zero-size vectors are represented by a single gate whose size() returns 0.) Gate names with the "$i" or "$o" suffix are also accepted. Throws an error if there is no such gate or gate vector.

Note: The gate vector size can also be obtained by calling the cGate::size() method of any gate object.

◆ gateBaseId()

virtual int gateBaseId ( const char *  gatename) const
virtual

For vector gates, it returns the ID of gate 0 in the vector, even if the gate size is currently zero. All gates in the vector can be accessed by ID = gateBaseId + index. For scalar gates, it returns the ID of the gate. If there is no such gate or gate vector, an error gets thrown.

Note: Gate IDs are guaranteed to be stable, i.e. they do not change if the gate vector gets resized, or other gates get added/removed.

◆ checkInternalConnections()

virtual bool checkInternalConnections ( ) const
virtual

For compound modules, it checks if all gates are connected inside the module (it returns true if they are OK); for simple modules, it returns true. This function is called during network setup.

◆ arrived()

virtual void arrived ( cMessage msg,
cGate ongate,
simtime_t  t 
)
virtual

This method is invoked as part of a send() call in another module. It is called when the message arrives at a gates in this module which is not further connected, that is, the gate's getNextGate() method returns nullptr. The default, cModule implementation reports an error ("message arrived at a compound module"), and the cSimpleModule implementation inserts the message into the FES after some processing.

Reimplemented in cSimpleModule.

◆ getAncestorPar()

virtual cPar& getAncestorPar ( const char *  parname)
virtual

Searches for the parameter in the parent modules, up to the system module. If the parameter is not found, throws cRuntimeError.

◆ getCanvas()

virtual cCanvas* getCanvas ( ) const
virtual

Returns the default canvas for this module, creating it if it hasn't existed before.

◆ getOsgCanvas()

virtual cOsgCanvas* getOsgCanvas ( ) const
virtual

Returns the default 3D (OpenSceneGraph) canvas for this module, creating it if it hasn't existed before.

◆ setBuiltinAnimationsAllowed()

virtual void setBuiltinAnimationsAllowed ( bool  enabled)
inlinevirtual

Sets whether built-in animations are requested on this module's graphical inspector.

◆ getBuiltinAnimationsAllowed()

virtual bool getBuiltinAnimationsAllowed ( ) const
inlinevirtual

Returns true if built-in animations are requested on this module's graphical inspector, and false otherwise.

◆ callInitialize() [1/2]

virtual void callInitialize ( )
overridevirtual

Interface for calling initialize() from outside.

Implements cComponent.

◆ callInitialize() [2/2]

virtual bool callInitialize ( int  stage)
overridevirtual

Interface for calling initialize() from outside. It does a single stage of initialization, and returns true if more stages are required.

Implements cComponent.

◆ callFinish()

virtual void callFinish ( )
overridevirtual

Interface for calling finish() from outside.

Implements cComponent.

◆ scheduleStart()

virtual void scheduleStart ( simtime_t  t)
virtual

Creates a starting message for modules that need it (and recursively for its submodules).

Reimplemented in cSimpleModule.

◆ deleteModule()

virtual void deleteModule ( )
virtual

Deletes the module and recursively all its submodules.

A running module can also delete itself. When an activity()-based simple module deletes itself from within its activity(), the deleteModule() call will not return (it throws an exception which gets caught by the simulation kernel, and the simulation kernel will delete the module).

When a handleMessage()-based module deletes itself, the deleteModule() returns normally – then, of course, the code should not try to access data members or functions of the deleted module, and should return as soon as possible.

It is not allowed to delete the system module. Also, a module cannot be deleted while its initialization is in progress.

◆ changeParentTo()

virtual void changeParentTo ( cModule mod)
virtual

Moves the module under a new parent module. This functionality may be useful for some (rare) mobility scenarios.

NOTE: THIS METHOD CHANGES THE MODULE ID. To maintain a time-independent moduleId-to-fullPath mapping, this method will cause this module, and all modules under it in the module hierarchy, to be assigned a new ID. This usually causes no problem in the simulation's operation, but if your model stores module IDs somewhere, you'll need to invalidate or update them manually.

This function could bypass several rules which are enforced when you build the model using NED, so you must observe the following:

  1. you cannot insert the module under one of its own submodules. This is checked by this function.
  2. gates of the module cannot be connected when you move it. If you moved a module which is connected to its parent module or to other submodules, you'd create connections that do not obey the module hierarchy, and this is not permitted. This rule is also enforced by the implementation of this function.
  3. it is recommended that the module name be made unique among the submodules of its new parent.
  4. be aware that if the module is part of a module vector, its isVector(), getIndex() and size() functions will continue to deliver the same info – although other elements of the vector will not necessarily be present under the same parent module.
See also
getId()

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