OMNeT++ Simulation Library  6.0.3
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 cSoftOwner 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. Iteration order corresponds to declaration order in NED files. 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 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 ()
 
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
 
Submodule access.
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
 
Gates.
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 void arrived (cMessage *msg, cGate *ongate, const SendOptions &options, 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 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
 

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

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 module's name. If the module is part of a submodule vector, the name change implies relocating the module into another submodule vector (which must already exist, and the same index position in it must be available and empty).

See also
setIndex(), setNameAndIndex()

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

Reimplemented in cSimpleModule.

◆ setIndex()

virtual void setIndex ( int  index)
virtual

Sets the module's index. The module must be part of a submodule vector. The index change implies relocating the module into another slot in the same submodule vector; the destination index position must be available and empty.

◆ setNameAndIndex()

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

Sets the module's name and index. If index is not -1, the change implies relocating the module into another submodule vector and index position. The destination submodule vector must already exist, and its indexth slot must be available and empty.

◆ addGate()

virtual cGate* addGate ( const char *  gatename,
cGate::Type  type 
)
virtual

Adds a scalar gate of the given type to the module. If type is INOUT, two gate objects will be created, "gatename$i" and "gatename$o" (the specified gatename must not contain a "$i" or "$o" suffix itself).

Returns a pointer to the new gate if type is INPUT or OUTPUT, and nullptr if type is INOUT.

◆ addGateVector()

virtual void addGateVector ( const char *  gatename,
cGate::Type  type,
int  size 
)
virtual

Adds a gate vector of the given type and size to the module. If type is INOUT, two gate vectors will be created, "gatename$i[]" and "gatename$o[]" (the specified gatename must not contain a "$i" or "$o" suffix itself).

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

Reimplemented in cSimpleModule.

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

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

Returns the index of the module in a module vector. If the module is not member of a module vector, an exception is thrown.

◆ getVectorSize()

int getVectorSize ( ) const

Returns the size of the module vector the module is in. If the module is not member of a module vector, an exception is thrown.

◆ hasSubmodules()

virtual bool hasSubmodules ( ) const
virtual

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

◆ hasSubmoduleVector()

virtual bool hasSubmoduleVector ( const char *  name) const
virtual

Returns true if the module has a submodule vector (not necessarily of nonzero size) of the given name, and false otherwise.

◆ getSubmoduleVectorNames()

virtual std::vector<std::string> getSubmoduleVectorNames ( ) const
virtual

Returns the names of the module's submodule vectors, including zero-size submodule vectors.

◆ getSubmoduleVectorSize()

virtual int getSubmoduleVectorSize ( const char *  name) const
virtual

Returns the size of the submodule vector of the given name. Throws an error if there is no such submodule vector.

◆ addSubmoduleVector()

virtual void addSubmoduleVector ( const char *  name,
int  size 
)
virtual

Adds a blank submodule vector with the given name and size. Throws an error if a submodule vector with the given name already exists.

Important: This operation does NOT actually create any submodules. The slots in the vector will be nullptr, i.e. getSubmodule(name,index) returns nullptr for all indices.

Modules can be added one by one by using cModuleType::create(name, parentModule, index). Deleting a module (via cModule::deleteModule()) which is part of a submodule vector will also remove it from the submodule vector and set its slot to nullptr.

◆ deleteSubmoduleVector()

virtual void deleteSubmoduleVector ( const char *  name)
virtual

Deletes the submodule vector with the given name. All submodules in the given vector will be deleted. Throws an error if a submodule vector with the given name does not exist.

◆ setSubmoduleVectorSize()

virtual void setSubmoduleVectorSize ( const char *  name,
int  size 
)
virtual

Resizes the given submodule vector, filling new elements with nullptr. A submodule vector can be extended any time; it can be shrunk only if it contains no submodules in the index range which is going to be removed. Throws an error if there is no such submodule vector, or the removed range contains submodules. Modules can be removed from the submodule vector by calling their deleteModule() method.

◆ addSubmodule()

virtual cModule* addSubmodule ( cModuleType type,
const char *  name,
int  index = -1 
)
virtual

Creates and initializes a submodule. If index is present, then the submodule becomes an element in a submodule vector; the submodule vector of the given name must already exist, have a sufficient size (size>index), and the indexth position must be empty.

Note: This method just delegates to cModuleType::createScheduleInit(). If parameters need to be set or gates need to be connected before building the internal structure (in case type is a compound module) and initializing the module, use cModuleType::create() instead of this method.

See also
cModuleType::createScheduleInit(), cModuleType::create()

◆ hasSubmodule()

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

Returns true if a submodule with the given name (and index) exists, and false otherwise. Index must be specified exactly if the module is member of a module vector.

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

◆ getSubmoduleNames()

virtual std::vector<std::string> getSubmoduleNames ( ) const
virtual

Returns the names of the module's submodules and submodule vectors, including zero-size submodule vectors.

◆ containsModule()

virtual bool containsModule ( cModule module) const
virtual

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

◆ hasGates()

virtual bool hasGates ( ) const
virtual

Returns true if the module has any gates, and false otherwise. If it does, getGateNames() or GateIterator be used to enumerate them.

◆ 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<std::string> 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.

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.

◆ hasGateVector()

virtual bool hasGateVector ( const char *  gatename) const
virtual

Returns true if there is a gate vector with the given name, and false otherwise. Names with the "$i" and "$o" suffix are also accepted. Zero-size gate vectors will also be included.

◆ 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. Gate names with the "$i" or "$o" suffix are also accepted. Throws an error if there is no such gate, or it is not a gate vector.

See also
cGate::getVectorSize()

◆ 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,
const SendOptions options,
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. if the module is part of a module vector, the new parent must already have a submodule vector of the same name, with size>index, and the corresponding (indexth) array element being vacant (nullptr).
See also
getId()

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