#include <cmodule.h>
Inheritance diagram for cModule::
Public Methods | |
Constructors, destructor, assignment. | |
cModule (const cModule &mod) | |
cModule (const char *name, cModule *parentmod) | |
virtual | ~cModule () |
cModule& | operator= (const cModule &mod) |
Redefined cObject functions. | |
virtual void | forEach (ForeachFunc f) |
virtual const char* | fullName () const |
virtual const char* | fullPath () const |
virtual const char* | fullPath (char *buffer, int bufsize) const |
Setting up the module. | |
virtual void | setId (int n) |
void | setIndex (int i, int n) |
void | setModuleType (cModuleType *mtype) |
cGate* | addGate (const char *s, char tp) |
void | setGateSize (const char *s, int size) |
cPar* | addPar (const char *s) |
void | addMachinePar (const char *pnam) |
void | setMachinePar (const char *pnam, const char *val) |
virtual int | buildInside () |
Information about the module itself. | |
virtual bool | isSimple () const=0 |
cModuleType* | moduleType () const |
int | id () const |
cModule* | parentModule () const |
bool | isOnLocalMachine () const |
bool | isVector () const |
int | index () const |
int | size () 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 | 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 |
Machine parameters (used by parallel execution). | |
int | machinePars () const |
const char* | machinePar (int i) |
const char* | machinePar (const char *machinename) |
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)=0 |
virtual void | callFinish ()=0 |
Dynamic module creation. | |
virtual void | scheduleStart (simtime_t t)=0 |
virtual void | deleteModule ()=0 |
Display strings. | |
const char* | displayString () |
void | setDisplayString (const char *dispstr, bool immediate=true) |
const char* | displayStringAsParent () |
void | setDisplayStringAsParent (const char *dispstr, bool immediate=true) |
const char* | displayString (int type) |
void | setDisplayString (int type, const char *dispstr, bool immediate=true) |
void | setDisplayStringNotify (DisplayStringNotifyFunc notify_func, void *data) |
Protected Methods | |
Initialization and finish 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 () |
NOTE: dup() cannot be use with modules. Use mod->moduleType()->create()
/buildInside()
instead.
|
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 machine parameter to the module. |
|
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 cException. |
|
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:
|
|
Interface for calling finish() from outside. Reimplemented in cSimpleModule, cCompoundModule, and cNetMod. |
|
Interface for calling initialize() from outside. It does a single stage of initialization, and returns Reimplemented in cSimpleModule, cCompoundModule, and cNetMod. |
|
Interface for calling initialize() from outside. Implements full multi-stage init for this module and its submodules. |
|
For compound modules, it checks if all gates are connected inside the module (it returns |
|
Deletes a dynamically created module and recursively all its submodules. This is a pure virtual function; it is redefined in both cCompoundModule and cSimpleModule. Reimplemented in cSimpleModule, cCompoundModule, and cNetMod. |
|
DEPRECATED. Use displayString() (without argument) or displayStringAsLocal() instead. |
|
Returns the first display string. This display string defines presentation when the module is displayed as a submodule in a compound module graphics. |
|
Returns the second display string. This display string is used when this module is a compound module whose internals are being displayed in a window. |
|
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. |
|
Call the passed function for each contained object. See cObject for more details. Reimplemented from cObject. 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. Returns NULL if the gate does not exist. |
|
Returns a gate by its ID. Returns NULL if the gate does not exist. |
|
Returns the total size of the gate array. Since the array may contain unused elements, the number of actual gates used might be less. |
|
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. |
|
Used with parallel execution: determines if the module is on the local machine. See the user manual for more info. |
|
Returns this is a simple or compound module. Pure virtual function, redefined in cSimpleModule to return true and in cCompoundModule to return false. Reimplemented in cSimpleModule, cCompoundModule, and cNetMod. |
|
Returns true if this module is in a module vector. |
|
Returns a machine parameter by its name. |
|
Returns the value of the ith machine parameter. |
|
Returns the number of machine parameters. |
|
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. Returns |
|
Returns reference to the module parameter identified with its index p. Returns |
|
Returns total number of the module's parameters. |
|
Returns the module's parent module. For the system module, it returns |
|
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. Reimplemented in cSimpleModule, cCompoundModule, and cNetMod. |
|
DEPRECATED. Use setDisplayString(dispstr,immediate) (without the type argument) or displayStringAsLocal(dispstr,immediate) instead. |
|
Sets the first display string for this module. This display string defines presentation when the module is displayed as a submodule in a compound module graphics. The immediate flag selects whether the change should become effective right now or later (after finishing the current event). If several display string changes are going to be done within one event, then immediate=false is useful because it reduces the number of necessary redraws. Immediate=false also uses less stack. But its drawback is that a setDisplayString() followed by a send() would actually be displayed in reverse order (message animation first), because message animations are performed immediately (actually within the send() call). |
|
Sets the second display string for this module. This display string is used when this module is a compound module whose internals are being displayed in a window. The immediate flag selects whether the change should become effective right now or later (after finishing the current event). If several display string changes are going to be done within one event, then immediate=false is useful because it reduces the number of necessary redraws. Immediate=false also uses less stack. But its drawback is that a setDisplayString() followed by a send() would actually be displayed in reverse order (message animation first), because message animations are performed immediately (actually within the send() call). |
|
Registers a notification function to be called when the display string changes. This function is used by graphical user interfaces (e.g. Tkenv) to get notified when the network graphics needs redraw due to a display string change. |
|
Sets gate vector size. |
|
Sets the module ID. Called internally as part of the module creation process. Reimplemented in cSimpleModule. |
|
Sets module index within vector (if module is part of a module vector). Called internally as part of the module creation process. |
|
Sets value of a machine parameter. |
|
Sets associated cModuleType for the module. Called internally as part of the module creation process. |
|
Returns the size of the module vector the module is in, or 1. |
|
Finds an immediate submodule with the given name and (optional) index, and returns its pointer. If the submodule was not found, returns NULL. |