#include <cmodule.h>
Inheritance diagram for cModule:
cModule provides gates, parameters, RNG mapping, display strings, and a set of virtual methods.
For navigating around in the module tree, see: parentModule(), submodule(), cSubModIterator, moduleByRelativePath(), cSimulation::moduleByPath().
Public Member Functions | |
Constructors, destructor, assignment. | |
cModule (const cModule &mod) | |
cModule () | |
virtual | ~cModule () |
cModule & | operator= (const cModule &mod) |
Redefined cObject functions. | |
virtual void | forEachChild (cVisitor *v) |
virtual void | setName (const char *s) |
virtual const char * | fullName () const |
virtual std::string | fullPath () const |
virtual const char * | fullPath (char *buffer, int bufsize) const |
Setting up the module. | |
cGate * | addGate (const char *s, char tp, bool isvector=false) |
int | setGateSize (const char *s, int size) |
cPar * | addPar (const char *s) |
virtual int | buildInside () |
Information about the module itself. | |
virtual bool | isSimple () const |
cModuleType * | moduleType () const |
int | id () const |
cModule * | parentModule () const |
bool | isVector () const |
int | index () const |
int | size () const |
cRNG * | rng (int k) const |
Submodule access. | |
int | findSubmodule (const char *submodname, int idx=-1) |
cModule * | submodule (const char *submodname, int idx=-1) |
cModule * | moduleByRelativePath (const char *path) |
Gates. | |
int | gates () const |
cGate * | gate (int g) |
const cGate * | gate (int g) const |
cGate * | gate (const char *gatename, int sn=-1) |
const cGate * | gate (const char *gatename, int sn=-1) const |
int | gateSize (const char *gatename) const |
int | findGate (const char *gatename, int sn=-1) const |
bool | hasGate (const char *gatename, int sn=-1) const |
bool | checkInternalConnections () const |
Parameters. | |
int | params () const |
cPar & | par (int p) |
cPar & | par (const char *parname) |
int | findPar (const char *parname) const |
cPar & | ancestorPar (const char *parname) |
bool | hasPar (const char *s) const |
Interface for calling initialize()/finish(). | |
Those functions may not be called directly, only via callInitialize() and callFinish() provided here. | |
virtual void | callInitialize () |
virtual bool | callInitialize (int stage) |
virtual void | callFinish () |
Dynamic module creation. | |
virtual void | scheduleStart (simtime_t t)=0 |
virtual void | deleteModule () |
virtual void | changeParentTo (cModule *mod) |
Display strings, animation. | |
cDisplayString & | displayString () |
cDisplayString & | backgroundDisplayString () |
void | setDisplayString (const char *dispstr, bool immediate=true) |
void | setBackgroundDisplayString (const char *dispstr, bool immediate=true) |
const char * | displayString (int type) |
void | setDisplayString (int type, const char *dispstr, bool immediate=true) |
void | bubble (const char *text) |
Protected Member Functions | |
Initialization, finish and parameter change hooks. | |
Initialize and finish functions should (may) be provided by the user, to perform special tasks at the beginning and the end of the simulation. The functions are made protected because they are supposed to be called only via callInitialize() and callFinish().
The initialization process was designed to support multi-stage initialization of compound modules (i.e. initialization in several 'waves'). (Calling the initialize() function of a simple module is hence a special case). The initialization process is performed on a module like this. First, the number of necessary initialization stages is determined by calling numInitStages(), then initialize(stage) is called with
All initialization and finish functions are redefined in cCompoundModule to recursively traverse all submodules. | |
virtual void | doBuildInside () |
virtual void | initialize (int stage) |
virtual int | numInitStages () const |
virtual void | initialize () |
virtual void | finish () |
virtual void | handleParameterChange (const char *parname) |
Friends | |
class | cGate |
class | cModulePar |
class | cSimulation |
class | cModuleType |
class | cSubModIterator |
|
Copy constructor.
|
|
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 |
|
Destructor.
|
|
Adds a gate.
The type character tp can be |
|
Adds a parameter to the module.
|
|
Searches for the parameter in the parent modules, up to the system module. It the parameter is not found, throws cRuntimeError. |
|
Returns the display string which is used when this module is a compound module whose internals are being displayed in a window.
|
|
When the models is running under Tkenv, it displays the given text in the network graphics, as a bubble above the module's icon.
|
|
In compound modules, this method can be called to build submodules and internal connections after module creation. This method is a wrapper around doBuildInside(). It does the following:
Note: semantic has changed -- in OMNeT++ 2.2 and earlier versions, doBuildInside() did not exist, its role was fulfilled by this method. After 2.2, the return value of this method was changed from void to int deliberately to cause compile error in older code, in order to call attention to the semantics change. (Returned value can be ignored.)
|
|
Interface for calling finish() from outside.
|
|
Interface for calling initialize() from outside.
It does a single stage of initialization, and returns |
|
Interface for calling initialize() from outside. Implements full multi-stage init for this module and its submodules. |
|
Moves the module under a new parent module. This functionality may be useful for some (rare) mobility scenarios. This function could bypass several rules which are enforced when you build the model using NED, so you must observe the following:
|
|
For compound modules, it checks if all gates are connected inside the module (it returns This function is usually called from from NEDC-generated code. |
|
Deletes the module and recursively all its submodules.
This method has to be used if a simple module wants to delete itself ( Reimplemented in cSimpleModule. |
|
DEPRECATED. Use displayString() or backgroundDisplayString(), plus cDisplayString methods instead. |
|
Returns the display string which defines presentation when the module is displayed as a submodule in a compound module graphics.
|
|
Should be refined in subclasses representing compound modules to build submodule and internal connections of this module. This default implementation does nothing. This method should not be called directly, only via buildInside(); this method is declared protected to enforce this.
|
|
Returns the ID of the gate specified by name and index. Returns -1 if the gate doesn't exist. |
|
Returns index of the module parameter specified with its name. Returns -1 if the object doesn't exist. |
|
Finds an immediate submodule with the given name and (optional) index, and returns its module ID. If the submodule was not found, returns -1. |
|
Finish hook. finish() is called after end of simulation, if it terminated without error. This default implementation does nothing. |
|
Calls v->visit(this) for each contained object. See cObject for more details. Reimplemented from cDefaultList. Reimplemented in cSimpleModule. |
|
Returns the full name of the module, which is name() plus the index in square brackets (e.g. "module[4]"). Redefined to add the index. Reimplemented from cObject. |
|
Returns the full path name of the module.
Example: Reimplemented from cObject. |
|
Redefined. (Reason: a C++ rule that overloaded virtual methods must be redefined together.) Reimplemented from cObject. |
|
Looks up a gate by its name and index. Returns NULL if the gate does not exist. |
|
Looks up a gate by its name and index. Returns NULL if the gate does not exist. |
|
Returns a gate by its ID. Note that the gate array may contain "holes", that is, this function can return NULL for some IDs in the 0..gates()-1 range. NULL is returned for IDs out of range as well. |
|
Returns a gate by its ID. Note that the gate array may contain "holes", that is, this function can return NULL for some IDs in the 0..gates()-1 range. NULL is returned for IDs out of range as well. |
|
Returns the total size of the gate array. Since the array may contain unused elements, the number of actual gates used might be less. |
|
Returns the size of the gate vector with the given name. It returns 1 for non-vector gates, and 0 if the gate doesn't exist or the vector has size 0. (Zero-size vectors are represented by a single gate whose size() returns 0.) The gate vector size can also be obtained by calling the cGate::size() method of any gate object in the vector. |
|
This method is called by the simulation kernel to notify the module that the value of an existing module parameter got changed. Redefining this method allows simple modules to be prepared for parameter changes, e.g. by re-reading the value. This default implementation does nothing. To make it easier to write predictable simple modules, the function does NOT get called during initialize() or finish(). If you need notifications within those two functions as well, add the following code to them:
for (int i=0; i<params(); i++) handleParameterChange(par(i).name()); Also, one must be extremely careful when changing parameters from inside handleParameterChange(), to avoid creating an infinite notification loop. |
|
Checks if a gate exists.
|
|
Check if a parameter exists.
|
|
Returns the module ID. It is actually the index of the module in the module vector within the cSimulation simulation object. Module IDs are guaranteed to be unique during a simulation run (that is, IDs of deleted modules are not given out to newly created modules). |
|
Returns the index of the module if it is in a module vector, otherwise 0.
|
|
Single-stage initialization hook. This default implementation does nothing. |
|
Multi-stage initialization hook. This default implementation does single-stage init, that is, calls initialize() if stage is 0. |
|
Convenience function. Returns true this is a simple module (i.e. subclassed from cSimpleModule), false otherwise. |
|
Returns true if this module is in a module vector.
|
|
Finds a submodule potentially several levels deeper, given with its relative path from this module.
(The path is a string of module full names separated by dots). If the submodule was not found, returns |
|
Returns the cModuleType object associated with this module type.
|
|
Multi-stage initialization hook, should be redefined to return the number of initialization stages required. This default implementation does single-stage init, that is, returns 1. |
|
Assignment operator. The name member doesn't get copied; see cObject's operator=() for more details. |
|
Returns reference to the module parameter specified with its name. Throws an error if the parameter does not exist. |
|
Returns reference to the module parameter identified with its index p. Throws an error if the parameter does not exist. |
|
Returns total number of the module's parameters.
|
|
Returns the module's parent module. For the system module, it returns NULL. |
|
Returns the RNG mapped to module local RNG number k. For large k (RNGs above the map size) are mapped one-to-one to physical RNGs, that is, rng(100) returns ev.rng(100) (provided it exists). |
|
Pure virtual function; it is redefined in both cCompoundModule and cSimpleModule. It creates starting message for dynamically created module (or recursively for its submodules). See the user manual for explanation how to use dynamically created modules. Implemented in cCompoundModule, and cSimpleModule. |
|
DEPRECATED. Use backgroundDisplayString() and cDisplayString methods instead. |
|
DEPRECATED. Use displayString() or backgroundDisplayString(), plus cDisplayString methods instead. |
|
DEPRECATED. Use displayString() and cDisplayString methods instead. |
|
Sets gate vector size. If the vector size is increased, Ids of existing gates in the vector may change. The function returns the new Id of the first gate in the vector. Note: setGateSize() should not be called when Id change can cause problems: after initialize() of this module has been invoked, or when messages have been sent to this module. In general, setGateSize() should only be used during creation of the module. (Id changes cannot be avoided with the current Id allocation scheme: Ids are guaranteed to be contiguous within a gate vector, and we issue small numbers as Ids, thus if the vector would expand to already issued gate Ids, the whole vector must be moved to a different Id range.) |
|
Sets object's name. Redefined to update the stored fullName string. Reimplemented from cObject. |
|
Returns the size of the module vector the module is in. For non-vector gates it returns 1. |
|
Finds an immediate submodule with the given name and (optional) index, and returns its pointer. If the submodule was not found, returns NULL. |