cComponent Class Reference
[Simulation core classes]

#include <ccomponent.h>

Inheritance diagram for cComponent:

cDefaultList cNoncopyableOwnedObject cOwnedObject noncopyable cNamedObject cObject cChannel cModule cDatarateChannel cDelayChannel cIdealChannel cCompoundModule cSimpleModule

List of all members.


Detailed Description

Common base for module and channel classes: cModule and cChannel.

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 cPropertiesgetProperties () const =0
cComponentTypegetComponentType () const
virtual const char * getNedTypeName () const
virtual bool isModule () const
virtual cModulegetParentModule () const =0
cRNGgetRNG (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 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
Display strings, animation.
cDisplayStringgetDisplayString ()
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 0,1,...numstages-1 as argument. The default implementation of numInitStages() and initialize(stage) provided here defaults to single-stage initialization, that is, numInitStages() returns 1 and initialize(stage) simply calls initialize() if stage is 0.

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


Constructor & Destructor Documentation

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.


Member Function Documentation

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]

Return the properties for this component.

Properties cannot be changed at runtime.

Implemented in cChannel, and cModule.

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]

Redefined to return true in cModule and subclasses, otherwise returns false.

Reimplemented in cModule.

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.

Implemented in cChannel, and cModule.

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]

Interface for calling initialize() from outside.

Implemented in cChannel, and cModule.

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.

Implemented in cChannel, and cModule.

virtual void cComponent::callFinish (  )  [pure virtual]

Interface for calling finish() from outside.

This method includes calling finish() of contained components (submodules, channels) as well.

Implemented in cChannel, and cModule.

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]

Check if a parameter exists.

References findPar().

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 
)

Records a double into the scalar result file.

Referenced by recordScalar().

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


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

Generated on Thu Feb 26 14:50:55 2009 for OMNeT++ Simulation Library by  doxygen 1.5.5