#include <ccomponent.h>

cComponent provides parameters, properties and RNG mapping.
Public Member Functions | |
| virtual void | finalizeParameters () |
Constructors, destructor, assignment. | |
| cComponent (const char *name=NULL) | |
| virtual | ~cComponent () |
Redefined cObject functions | |
| virtual void | forEachChild (cVisitor *v) |
Misc. | |
| virtual cProperties * | getProperties () const =0 |
| cComponentType * | getComponentType () const |
| virtual const char * | getNedTypeName () const |
| virtual bool | isModule () const |
| virtual cModule * | getParentModule () const =0 |
| cRNG * | getRNG (int k) const |
Interface for calling initialize()/finish(). | |
Those functions may not be called directly, only via callInitialize() and callFinish() provided here. | |
| virtual void | callInitialize ()=0 |
| virtual bool | callInitialize (int stage)=0 |
| virtual void | callFinish ()=0 |
Parameters. | |
| virtual int | getNumParams () const |
| virtual cPar & | par (int k) |
| const cPar & | par (int k) const |
| virtual cPar & | par (const char *parname) |
| const cPar & | par (const char *parname) const |
| virtual int | findPar (const char *parname) const |
| bool | hasPar (const char *s) const |
Display strings, animation. | |
| cDisplayString & | getDisplayString () |
| void | setDisplayString (const char *dispstr) |
| void | bubble (const char *text) |
Statistics collection | |
| void | recordScalar (const char *name, double value, const char *unit=NULL) |
| void | recordScalar (const char *name, SimTime value, const char *unit=NULL) |
| void | recordStatistic (cStatistic *stats, const char *unit=NULL) |
| void | recordStatistic (const char *name, cStatistic *stats, const char *unit=NULL) |
Protected Member Functions | |
Initialization, finish and parameter change hooks. | |
Initialize and finish functions 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 | |
| virtual void | initialize (int stage) |
| virtual int | numInitStages () const |
| virtual void | initialize () |
| virtual void | finish () |
| virtual void | handleParameterChange (const char *parname) |
Friends | |
| class | cPar |
| class | cChannel |
| class | cModule |
| cComponent::cComponent | ( | const char * | name = NULL |
) |
Constructor.
Note that module and channel objects should not be created directly, via their cComponentType objects. cComponentType::create() will do all housekeeping associated with creating the getModule(assigning an ID to the module, inserting it into the simulation object, etc.).
| virtual cComponent::~cComponent | ( | ) | [virtual] |
Destructor.
| virtual void cComponent::initialize | ( | int | stage | ) | [inline, protected, virtual] |
Multi-stage initialization hook.
This default implementation does single-stage init, that is, calls initialize() if stage is 0.
References initialize().
| virtual int cComponent::numInitStages | ( | ) | const [inline, protected, virtual] |
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.
| virtual void cComponent::initialize | ( | ) | [protected, virtual] |
Single-stage initialization hook.
This default implementation does nothing.
Referenced by initialize().
| virtual void cComponent::finish | ( | ) | [protected, virtual] |
Finish hook.
finish() is called after end of simulation, if it terminated without error. This default implementation does nothing.
| virtual void cComponent::handleParameterChange | ( | const char * | parname | ) | [protected, virtual] |
This method is called by the simulation kernel to notify the module or channel that the value of an existing parameter got changed.
Redefining this method allows simple modules and channels to be react on parameter changes, for example 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 into your initialize() and/or finish() methods:
for (int i=0; i<getNumParams(); i++) handleParameterChange(par(i).getName());
Also, one must be extremely careful when changing parameters from inside handleParameterChange(), to avoid creating an infinite notification loop.
Reimplemented in cDatarateChannel, and cDelayChannel.
| virtual void cComponent::forEachChild | ( | cVisitor * | v | ) | [virtual] |
Redefined to include component parameters in the traversal as well.
Reimplemented from cDefaultList.
Reimplemented in cChannel, cModule, and cSimpleModule.
| virtual void cComponent::finalizeParameters | ( | ) | [virtual] |
Must be called after the component was created, and (with modules) before buildInside().
It reads input parameters from omnetpp.ini, and cModule extends this method to add gates to the module too (as this is the earliest time parameter values are available, and gate vector sizes may depend on parameters).
Reimplemented in cChannel, cDatarateChannel, cDelayChannel, and cModule.
| virtual cProperties* cComponent::getProperties | ( | ) | const [pure virtual] |
| cComponentType* cComponent::getComponentType | ( | ) | const |
Returns the associated component type.
Guaranteed to be non-NULL.
Referenced by cChannel::getChannelType().
| virtual const char* cComponent::getNedTypeName | ( | ) | const [virtual] |
Returns the fully qualified NED type name of the component (i.e.
the simple name prefixed with the package name and any existing enclosing NED type names).
This method is a shortcut to getComponentType()->getFullName().
| virtual bool cComponent::isModule | ( | ) | const [inline, virtual] |
| virtual cModule* cComponent::getParentModule | ( | ) | const [pure virtual] |
Returns the module containing this module/channel.
This is not necessarily the same object as getOwner(), especially for channel objects. For the system module, it returns NULL.
| cRNG* cComponent::getRNG | ( | int | k | ) | const [inline] |
Returns the global RNG mapped to local RNG number k.
For large indices (k >= map size) the global RNG k is returned, provided it exists.
References ev.
| virtual void cComponent::callInitialize | ( | ) | [pure virtual] |
| virtual bool cComponent::callInitialize | ( | int | stage | ) | [pure virtual] |
Interface for calling initialize() from outside.
It does a single stage of initialization, and returns true if more stages are required.
| virtual void cComponent::callFinish | ( | ) | [pure virtual] |
| virtual int cComponent::getNumParams | ( | ) | const [inline, virtual] |
Returns total number of the component's parameters.
| virtual cPar& cComponent::par | ( | int | k | ) | [virtual] |
Returns reference to the parameter identified with its index k.
Throws an error if the parameter does not exist.
Referenced by par().
| const cPar& cComponent::par | ( | int | k | ) | const [inline] |
Returns reference to the parameter identified with its index k.
Throws an error if the parameter does not exist.
References par().
| virtual cPar& cComponent::par | ( | const char * | parname | ) | [virtual] |
Returns reference to the parameter specified with its name.
Throws an error if the parameter does not exist.
| const cPar& cComponent::par | ( | const char * | parname | ) | const [inline] |
Returns reference to the parameter specified with its name.
Throws an error if the parameter does not exist.
References par().
| virtual int cComponent::findPar | ( | const char * | parname | ) | const [virtual] |
Returns index of the parameter specified with its name.
Returns -1 if the object doesn't exist.
Referenced by hasPar().
| bool cComponent::hasPar | ( | const char * | s | ) | const [inline] |
| cDisplayString& cComponent::getDisplayString | ( | ) |
Returns the display string which defines presentation when the module is displayed as a submodule in a compound module graphics.
| void cComponent::setDisplayString | ( | const char * | dispstr | ) |
Shortcut to getDisplayString().set(dispstr).
| void cComponent::bubble | ( | const char * | text | ) |
When the models is running under Tkenv, it displays the given text in the network graphics, as a bubble above the module's icon.
| void cComponent::recordScalar | ( | const char * | name, | |
| double | value, | |||
| const char * | unit = NULL | |||
| ) |
| void cComponent::recordScalar | ( | const char * | name, | |
| SimTime | value, | |||
| const char * | unit = NULL | |||
| ) | [inline] |
Convenience method, delegates to recordScalar(const char *, double).
References SimTime::dbl(), and recordScalar().
| void cComponent::recordStatistic | ( | cStatistic * | stats, | |
| const char * | unit = NULL | |||
| ) |
Records the given statistics into the scalar result file.
Delegates to cStatistic::recordAs().
| void cComponent::recordStatistic | ( | const char * | name, | |
| cStatistic * | stats, | |||
| const char * | unit = NULL | |||
| ) |
Records the given statistics into the scalar result file with the given name.
Delegates to cStatistic::recordAs().
1.5.5