cComponent Class Reference¶

API: cComponent Class Reference
API
cComponent Class Referenceabstract
Inheritance diagram for cComponent:
[legend]

Public Member Functions

Constructors, destructor, assignment.
 cComponent (const char *name=nullptr)
virtual ~cComponent ()
Redefined cObject functions
virtual void forEachChild (cVisitor *v) override
const cComponentgetThisPtr () const
virtual void finalizeParameters ()
Misc.
virtual cPropertiesgetProperties () const =0
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
virtual ComponentKind getComponentKind () const =0
bool isModule () const
bool isChannel () const
virtual cModulegetParentModule () const =0
virtual cModulegetSystemModule () const
virtual cModulegetModuleByPath (const char *path) const
virtual cModulefindModuleByPath (const char *path) 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
Basic random number generation.
virtual int getNumRNGs () const
virtual cRNGgetRNG (int k) const
virtual uint32_t intrand (uint32_t r, int rng=0) const
virtual double dblrand (int rng=0) const
Random variate generation – continuous distributions.
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
Random variate generation – discrete distributions.
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
Subscribing to simulation signals.
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
Display strings, animation.
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
Statistics collection
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)
Public Member Functions inherited from cSoftOwner
 cSoftOwner (const char *name=nullptr, bool namepooling=true)
virtual ~cSoftOwner ()
virtual bool isSoftOwner () const override
virtual std::string str () 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 void setName (const char *s)
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 const char * getFullName () const
virtual std::string getFullPath () 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

Protected Member Functions

Initialization, finalization, and various other 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)
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)

Emitting simulation signals.

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
static simsignal_t registerSignal (const char *name)
static const char * getSignalName (simsignal_t signalID)

Additional Inherited Members

Static Public Member Functions inherited from cOwnedObject
static long getTotalObjectCount ()
static long getLiveObjectCount ()
static void resetObjectCounters ()
static cSoftOwnergetOwningContext ()

Description

Common base for module and channel classes.

cComponent provides parameters, properties, display string, RNG mapping, initialization and finalization support, simulation signals support, and several other services to its subclasses.

Constructor & Destructor Documentation

◆ cComponent()

cComponent ( const char * name = nullptr)

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 module (assigning an ID to the module, inserting it into the simulation object, etc.).

Referenced by cChannel::finalizeParameters(), getThisPtr(), par(), par(), and preDelete().

◆ ~cComponent()

virtual ~cComponent ( )
virtual

Destructor.

Member Function Documentation

◆ initialize() [1/2]

virtual void initialize ( int stage)
inlineprotectedvirtual

Multi-stage initialization hook. This default implementation does single-stage init, that is, calls initialize() if stage is 0.

References initialize().

Referenced by initialize().

◆ numInitStages()

virtual int numInitStages ( ) const
inlineprotectedvirtual

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.

◆ initialize() [2/2]

virtual void initialize ( )
protectedvirtual

Single-stage initialization hook. This default implementation does nothing.

Reimplemented in cDatarateChannel, and cDelayChannel.

◆ finish()

virtual void finish ( )
protectedvirtual

Finish hook. finish() is called after end of simulation if it terminated without error. This default implementation does nothing.

Reimplemented in cDatarateChannel.

◆ handleParameterChange()

virtual void handleParameterChange ( const char * parname)
protectedvirtual

This method is called by the simulation kernel to notify the module or channel that the value of an existing parameter has 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.

Notification is initially disabled until all parameters have been set up, that is, until finalizeParameters() is invoked on this component. However, notifications are enabled while the component goes through (single or multi-stage) initialization. When implementing handleParameterChange(), one must keep in mind that the component may not have been fully initialized at the time of the call (e.g. may not have gone through all init stages yet).

One must be extremely careful when changing parameters from inside handleParameterChange(), to avoid creating infinite notification loops.

Note: Before OMNeT++ version 6.0, handleParameterChange() was disabled during the whole initialization process, and handleParameterChange(nullptr) was called after the last stage of the initialization. This is no longer so in version 6.0 or later.

Reimplemented in cDatarateChannel, and cDelayChannel.

◆ refreshDisplay()

virtual void refreshDisplay ( ) const
protectedvirtual

This method is called on all components of the simulation by graphical user interfaces like Qtenv, whenever GUI contents need to be refreshed after processing some simulation events. Components that contain visualization-related code are expected to override refreshDisplay(), and move visualization code display string manipulation, canvas figures maintenance, OSG scene graph update, etc.) into it.

As it is unpredictable when and whether this method is invoked, the simulation logic should not depend on it. It is advisable that code in refreshDisplay() does not alter the state of the model at all. This behavior is gently encouraged by having this method declared as const. (Data members that do need to be updated inside refreshDisplay(), i.e. those related to visualization, may be declared mutable to allow that).

Qtenv invokes refreshDisplay() in Step and Run mode, after each event; in Fast Run and Express Run mode, every time the screen is refreshed, which is typically on the order of once per second. Cmdenv does not invoke refreshDisplay() at all.

Note that overriding refreshDisplay() is generally preferable to doing display updates as part of event handling: it results in essentially zero per-event runtime overhead, and potentially more consistent information being displayed (as all components refresh their visualization, not only the one which has just processed an event.)

◆ preDelete()

virtual void preDelete ( cComponent * root)
protectedvirtual

This method is called when a module tree or a channel object is deleted (see cModule::deleteModule() and cGate::disconnect()) before any change is done. The default implementation recurses on all modules and channels that are going to be deleted. This method can be viewed as a dual of component initialization, i.e. the initialize() function.

The argument contains the module on which deleteModule() was called, or the channel which being deleted e.g. due to gate disconnection.

Overriding this method allows one to unsubscribe from model change notifications or perform other deinitialization tasks to simplify the job of the destructors.

References cComponent().

◆ forEachChild()

virtual void forEachChild ( cVisitor * v)
overridevirtual

Redefined to include component parameters in the traversal as well.

Reimplemented from cSoftOwner.

Reimplemented in cModule, and cSimpleModule.

◆ getThisPtr()

const cComponent * getThisPtr ( ) const
inline

Returns the this pointer. Utility function for the logging macros. Redefined to change the return type.

References cComponent().

◆ finalizeParameters()

virtual void 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, and cModule.

◆ getProperties()

virtual cProperties * getProperties ( ) const
pure virtual

Return the properties for this component. Properties cannot be changed at runtime.

Implemented in cChannel, and cModule.

◆ setDisplayName()

virtual void setDisplayName ( const char * name)
virtual

Sets the display name of the component, an alternative name that may be displayed on graphical user interfaces like Qtenv or the Sequence Chart. Pass nullptr to clear the display name.

◆ getDisplayName()

virtual const char * getDisplayName ( ) const
inlinevirtual

Returns the display name of the module, an alternative name that may be displayed on graphical user interfaces like Qtenv or the Sequence Chart. Returns nullptr if a display name is not set.

◆ getComponentType()

virtual cComponentType * getComponentType ( ) const
virtual

Returns the associated component type. Guaranteed to be non-nullptr.

Referenced by cChannel::getChannelType(), and cModule::getModuleType().

◆ getSimulation()

cSimulation * getSimulation ( ) const
inline

Returns the simulation the component is part of.

◆ getId()

int getId ( ) const
inline

Returns the component's ID in the simulation object (cSimulation). Component IDs are guaranteed to be unique during a simulation run (that is, IDs of deleted components are not reused for new components.)

See also
getSimulation(), cSimulation::getComponent(), cSimulation::getModule(), cSimulation::getChannel()

Referenced by cTopology::createNode().

◆ getNedTypeName()

virtual const char * 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().

◆ getNedTypeAndFullName()

virtual std::string getNedTypeAndFullName ( ) const
virtual

Returns a string that contains the NED type name and the full name of the component in a human-friendly format. Example: "(StandardHost)host[2]"

See also
getClassAndFullName()

◆ getNedTypeAndFullPath()

virtual std::string getNedTypeAndFullPath ( ) const
virtual

Returns a string that contains the NED type name and the full path of the component in a human-friendly format. Example: "(StandardHost)Network.subnet1.host[2]"

See also
getClassAndFullPath()

◆ getComponentKind()

virtual ComponentKind getComponentKind ( ) const
pure virtual

Returns the kind of the component.

See also
isModule(), isChannel()

Implemented in cChannel, and cModule.

Referenced by isChannel(), and isModule().

◆ isModule()

bool isModule ( ) const
inline

Returns true for cModule and subclasses, otherwise false.

References getComponentKind().

Referenced by cSimulation::getModule().

◆ isChannel()

bool isChannel ( ) const
inline

Returns true for channels, and false otherwise.

References getComponentKind().

Referenced by cSimulation::getChannel().

◆ getParentModule()

virtual cModule * 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 nullptr.

Implemented in cChannel, and cModule.

◆ getSystemModule()

virtual cModule * getSystemModule ( ) const
virtual

Returns the toplevel module in the current simulation. This is a shortcut to getSimulation()->getSystemModule().

◆ getModuleByPath()

virtual cModule * getModuleByPath ( const char * path) const
virtual

Finds a module in the module tree, given by its absolute or relative path. The path is a string of module names separated by dots; the special module name ^ (caret) stands for the parent module. If the path starts with a dot or caret, it is understood as relative to this module/channel, otherwise it is taken to mean an absolute path. For absolute paths, inclusion of the toplevel module's name in the path is optional. The toplevel module may also be referred to as "<root>".

This method never returns nullptr. If the module was not found, an exception is thrown.

Examples: "." means this module; "<root>" means the toplevel module; ".sink" means the sink submodule of this module; ".queue[2].srv" means the srv submodule of the queue[2] submodule; "^.host2" or ".^.host2" means the host2 sibling module; "src" or "<root>.src" means the src submodule of the toplevel module; "Net.src" also means the src submodule of the toplevel module, provided it is called Net.

See also
findModuleByPath(), cSimulation::getModuleByPath()

◆ findModuleByPath()

virtual cModule * findModuleByPath ( const char * path) const
virtual

Finds a module in the module tree, given by its absolute or relative path. This method is similar to getModuleByPath(); the only difference is that while getModuleByPath() throws an exception if the module was not found, this method returns nullptr in that case.

See also
getModuleByPath(), cSimulation::findModuleByPath()

◆ callInitialize() [1/2]

virtual void callInitialize ( )
pure virtual

Interface for calling initialize() from outside.

Implemented in cChannel, and cModule.

◆ callInitialize() [2/2]

virtual bool 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.

◆ callFinish()

virtual void 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.

◆ getNumParams()

virtual int getNumParams ( ) const
inlinevirtual

Returns total number of the component's parameters.

◆ par() [1/4]

virtual cPar & par ( int k)
virtual

Returns reference to the parameter identified with its index k. Throws an error if the parameter does not exist.

◆ par() [2/4]

const cPar & 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 cComponent(), and par().

Referenced by par().

◆ par() [3/4]

virtual cPar & par ( const char * parname)
virtual

Returns reference to the parameter specified with its name. Throws an error if the parameter does not exist.

◆ par() [4/4]

const cPar & 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 cComponent(), and par().

Referenced by par().

◆ findPar()

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

◆ hasPar()

bool hasPar ( const char * s) const
inline

Check if a parameter exists.

References findPar().

◆ getNumRNGs()

virtual int getNumRNGs ( ) const
virtual

Returns the number of RNGs available for this component.

◆ getRNG()

virtual cRNG * getRNG ( int k) const
virtual

◆ intrand()

virtual uint32_t intrand ( uint32_t r,
int rng = 0 ) const
inlinevirtual

Produces a random integer in the range [0,r) using the RNG given with its index.

References getRNG().

◆ dblrand()

virtual double dblrand ( int rng = 0) const
inlinevirtual

Produces a random double in the range [0,1) using the RNG given with its index.

References getRNG().

◆ uniform() [1/2]

virtual double uniform ( double a,
double b,
int rng = 0 ) const
inlinevirtual

Returns a random variate with uniform distribution in the range [a,b).

Parameters
a,bthe interval, a<b
rngindex of the component RNG to use, see getRNG(int)

References getRNG(), and omnetpp::uniform().

◆ uniform() [2/2]

virtual SimTime uniform ( SimTime a,
SimTime b,
int rng = 0 ) const
inlinevirtual

SimTime version of uniform(double,double,int), for convenience.

References SimTime::dbl(), and uniform().

Referenced by uniform().

◆ exponential() [1/2]

virtual double exponential ( double mean,
int rng = 0 ) const
inlinevirtual

Returns a random variate from the exponential distribution with the given mean (that is, with parameter lambda=1/mean).

Parameters
meanmean value
rngindex of the component RNG to use, see getRNG(int)

References omnetpp::exponential(), and getRNG().

◆ exponential() [2/2]

virtual SimTime exponential ( SimTime mean,
int rng = 0 ) const
inlinevirtual

SimTime version of exponential(double,int), for convenience.

References SimTime::dbl(), and exponential().

Referenced by exponential().

◆ normal() [1/2]

virtual double normal ( double mean,
double stddev,
int rng = 0 ) const
inlinevirtual

Returns a random variate from the normal distribution with the given mean and standard deviation.

Parameters
meanmean of the normal distribution
stddevstandard deviation of the normal distribution
rngindex of the component RNG to use, see getRNG(int)

References getRNG(), and omnetpp::normal().

◆ normal() [2/2]

virtual SimTime normal ( SimTime mean,
SimTime stddev,
int rng = 0 ) const
inlinevirtual

SimTime version of normal(double,double,int), for convenience.

References SimTime::dbl(), and normal().

Referenced by normal().

◆ truncnormal() [1/2]

virtual double truncnormal ( double mean,
double stddev,
int rng = 0 ) const
inlinevirtual

Normal distribution truncated to nonnegative values. It is implemented with a loop that discards negative values until a nonnegative one comes. This means that the execution time is not bounded: a large negative mean with much smaller stddev is likely to result in a large number of iterations.

The mean and stddev parameters serve as parameters to the normal distribution before truncation. The actual random variate returned will have a different mean and standard deviation.

Parameters
meanmean of the normal distribution
stddevstandard deviation of the normal distribution
rngindex of the component RNG to use, see getRNG(int)

References getRNG(), and omnetpp::truncnormal().

◆ truncnormal() [2/2]

virtual SimTime truncnormal ( SimTime mean,
SimTime stddev,
int rng = 0 ) const
inlinevirtual

SimTime version of truncnormal(double,double,int), for convenience.

References SimTime::dbl(), and truncnormal().

Referenced by truncnormal().

◆ gamma_d()

virtual double gamma_d ( double alpha,
double theta,
int rng = 0 ) const
inlinevirtual

Returns a random variate from the gamma distribution with parameters alpha>0, theta>0. Alpha is known as the "shape" parameter, and theta as the "scale" parameter.

Some sources in the literature use the inverse scale parameter beta = 1 / theta, called the "rate" parameter. Various other notations can be found in the literature; our usage of (alpha,theta) is consistent with Wikipedia and Mathematica (Wolfram Research).

Gamma is the generalization of the Erlang distribution for non-integer k values, which becomes the alpha parameter. The chi-square distribution is a special case of the gamma distribution.

For alpha=1, Gamma becomes the exponential distribution with mean=theta.

The mean of this distribution is alpha*theta, and variance is alpha*theta2.

Generation: if alpha=1, it is generated as exponential(theta).

For alpha>1, we make use of the acceptance-rejection method in "A Simple Method for Generating Gamma Variables", George Marsaglia and Wai Wan Tsang, ACM Transactions on Mathematical Software, Vol. 26, No. 3, September 2000.

The alpha<1 case makes use of the alpha>1 algorithm, as suggested by the above paper.

Remarks
the name gamma_d is chosen to avoid ambiguity with a function of the same name
Parameters
alpha>0 the "shape" parameter
theta>0 the "scale" parameter
rngindex of the component RNG to use, see getRNG(int)

References omnetpp::gamma_d(), and getRNG().

◆ beta()

virtual double beta ( double alpha1,
double alpha2,
int rng = 0 ) const
inlinevirtual

Returns a random variate from the beta distribution with parameters alpha1, alpha2.

Generation is using relationship to Gamma distribution: if Y1 has gamma distribution with alpha=alpha1 and beta=1 and Y2 has gamma distribution with alpha=alpha2 and beta=2, then Y = Y1/(Y1+Y2) has beta distribution with parameters alpha1 and alpha2.

Parameters
alpha1,alpha2>0
rngindex of the component RNG to use, see getRNG(int)

References omnetpp::beta(), and getRNG().

◆ erlang_k()

virtual double erlang_k ( unsigned int k,
double mean,
int rng = 0 ) const
inlinevirtual

Returns a random variate from the Erlang distribution with k phases and mean mean.

This is the sum of k mutually independent random variables, each with exponential distribution. Thus, the kth arrival time in the Poisson process follows the Erlang distribution.

Erlang with parameters m and k is gamma-distributed with alpha=k and beta=m/k.

Generation makes use of the fact that exponential distributions sum up to Erlang.

Parameters
knumber of phases, k>0
mean>0
rngindex of the component RNG to use, see getRNG(int)

References omnetpp::erlang_k(), and getRNG().

◆ chi_square()

virtual double chi_square ( unsigned int k,
int rng = 0 ) const
inlinevirtual

Returns a random variate from the chi-square distribution with k degrees of freedom. The chi-square distribution arises in statistics. If Yi are k independent random variates from the normal distribution with unit variance, then the sum-of-squares (sum(Yi^2)) has a chi-square distribution with k degrees of freedom.

The expected value of this distribution is k. Chi_square with parameter k is gamma-distributed with alpha=k/2, beta=2.

Generation is using relationship to gamma distribution.

Parameters
kdegrees of freedom, k>0
rngindex of the component RNG to use, see getRNG(int)

References omnetpp::chi_square(), and getRNG().

◆ student_t()

virtual double student_t ( unsigned int i,
int rng = 0 ) const
inlinevirtual

Returns a random variate from the student-t distribution with i degrees of freedom. If Y1 has a normal distribution and Y2 has a chi-square distribution with k degrees of freedom then X = Y1 / sqrt(Y2/k) has a student-t distribution with k degrees of freedom.

Generation is using relationship to gamma and chi-square.

Parameters
idegrees of freedom, i>0
rngindex of the component RNG to use, see getRNG(int)

References getRNG(), and omnetpp::student_t().

◆ cauchy()

virtual double cauchy ( double a,
double b,
int rng = 0 ) const
inlinevirtual

Returns a random variate from the Cauchy distribution (also called Lorentzian distribution) with parameters a,b where b>0.

This is a continuous distribution describing resonance behavior. It also describes the distribution of horizontal distances at which a line segment tilted at a random angle cuts the x-axis.

Generation uses inverse transform.

Parameters
a
bb>0
rngindex of the component RNG to use, see getRNG(int)

References omnetpp::cauchy(), and getRNG().

◆ triang()

virtual double triang ( double a,
double b,
double c,
int rng = 0 ) const
inlinevirtual

Returns a random variate from the triangular distribution with parameters a <= b <= c.

Generation uses inverse transform.

Parameters
a,b,ca <= b <= c
rngindex of the component RNG to use, see getRNG(int)

References getRNG(), and omnetpp::triang().

◆ lognormal()

virtual double lognormal ( double m,
double w,
int rng = 0 ) const
inlinevirtual

Returns a random variate from the lognormal distribution with "scale" parameter m and "shape" parameter w. m and w correspond to the parameters of the underlying normal distribution (m: mean, w: standard deviation.)

Generation is using relationship to normal distribution.

Parameters
m"scale" parameter, m>0
w"shape" parameter, w>0
rngindex of the component RNG to use, see getRNG(int)

References getRNG(), and omnetpp::lognormal().

◆ weibull()

virtual double weibull ( double a,
double b,
int rng = 0 ) const
inlinevirtual

Returns a random variate from the Weibull distribution with parameters a, b > 0, where a is the "scale" parameter and b is the "shape" parameter. Sometimes Weibull is given with alpha and beta parameters, then alpha=b and beta=a.

The Weibull distribution gives the distribution of lifetimes of objects. It was originally proposed to quantify fatigue data, but it is also used in reliability analysis of systems involving a "weakest link," e.g. in calculating a device's mean time to failure.

When b=1, Weibull(a,b) is exponential with mean a.

Generation uses inverse transform.

Parameters
athe "scale" parameter, a>0
bthe "shape" parameter, b>0
rngindex of the component RNG to use, see getRNG(int)

References getRNG(), and omnetpp::weibull().

◆ pareto_shifted()

virtual double pareto_shifted ( double a,
double b,
double c,
int rng = 0 ) const
inlinevirtual

Returns a random variate from the shifted generalized Pareto distribution.

Generation uses inverse transform.

Parameters
a,bthe usual parameters for generalized Pareto
cshift parameter for left-shift
rngindex of the component RNG to use, see getRNG(int)

References getRNG(), and omnetpp::pareto_shifted().

◆ intuniform()

virtual int intuniform ( int a,
int b,
int rng = 0 ) const
inlinevirtual

Returns a random integer with uniform distribution in the range [a,b], inclusive. (Note that the function can also return b.)

Parameters
a,bthe interval, a<=b
rngindex of the component RNG to use, see getRNG(int)

References getRNG(), and omnetpp::intuniform().

◆ intuniformexcl()

virtual int intuniformexcl ( int a,
int b,
int rng = 0 ) const
inlinevirtual

Returns a random integer with uniform distribution over [a,b), that is, from [a,b-1].

Parameters
a,bthe interval, a<b
rngindex of the component RNG to use, see getRNG(int)

References getRNG(), and omnetpp::intuniformexcl().

◆ bernoulli()

virtual int bernoulli ( double p,
int rng = 0 ) const
inlinevirtual

Returns the result of a Bernoulli trial with probability p, that is, 1 with probability p and 0 with probability (1-p).

Generation is using elementary look-up.

Parameters
p0=<p<=1
rngindex of the component RNG to use, see getRNG(int)

References omnetpp::bernoulli(), and getRNG().

◆ binomial()

virtual int binomial ( int n,
double p,
int rng = 0 ) const
inlinevirtual

Returns a random integer from the binomial distribution with parameters n and p, that is, the number of successes in n independent trials with probability p.

Generation is using the relationship to Bernoulli distribution (runtime is proportional to n).

Parameters
nn>=0
p0<=p<=1
rngindex of the component RNG to use, see getRNG(int)

References omnetpp::binomial(), and getRNG().

◆ geometric()

virtual int geometric ( double p,
int rng = 0 ) const
inlinevirtual

Returns a random integer from the geometric distribution with parameter p, that is, the number of independent trials with probability p until the first success.

This is the n=1 special case of the negative binomial distribution.

Generation uses inverse transform.

Parameters
p0<p<=1
rngindex of the component RNG to use, see getRNG(int)

References omnetpp::geometric(), and getRNG().

◆ negbinomial()

virtual int negbinomial ( int n,
double p,
int rng = 0 ) const
inlinevirtual

Returns a random integer from the negative binomial distribution with parameters n and p, that is, the number of failures occurring before n successes in independent trials with probability p of success.

Generation is using the relationship to geometric distribution (runtime is proportional to n).

Parameters
nn>=0
p0<p<1
rngindex of the component RNG to use, see getRNG(int)

References getRNG(), and omnetpp::negbinomial().

◆ poisson()

virtual int poisson ( double lambda,
int rng = 0 ) const
inlinevirtual

Returns a random integer from the Poisson distribution with parameter lambda, that is, the number of arrivals over unit time where the time between successive arrivals follow exponential distribution with parameter lambda.

Lambda is also the mean (and variance) of the distribution.

Generation method depends on value of lambda:

  • 0<lambda<=30: count number of events
  • lambda>30: Acceptance-Rejection due to Atkinson (see Banks, page 166)
Parameters
lambda> 0
rngindex of the component RNG to use, see getRNG(int)

References getRNG(), and omnetpp::poisson().

◆ registerSignal()

simsignal_t registerSignal ( const char * name)
static

Returns the signal ID (handle) for the given signal name. Signal names and IDs are global. The signal ID for a particular name gets assigned at the first registerSignal() call; further registerSignal() calls for the same name will return the same ID.

Note: Since OMNeT++ 4.3, the signal registration table is not cleared between runs, so it is possible to assign global simsignal_t variables using static initialization:

simsignal_t somethingHappenedSignal = cComponent::registerSignal("somethingHappened");
static simsignal_t registerSignal(const char *name)
int simsignal_t
Signal handle.
Definition clistener.h:37

◆ getSignalName()

const char * getSignalName ( simsignal_t signalID)
static

The inverse of registerSignal(): returns the name of the given signal, or nullptr for invalid signal handles.

◆ emit() [1/18]

virtual void emit ( simsignal_t signalID,
bool b,
cObject * details = nullptr )
virtual

Emits the boolean value as a signal. If the given signal has listeners in this component or in ancestor components, their appropriate receiveSignal() methods are called. If there are no listeners, the runtime cost is usually minimal.

◆ emit() [2/18]

virtual void emit ( simsignal_t signalID,
double d,
cObject * details = nullptr )
virtual

Emits the double value as a signal. If the given signal has listeners in this component or in ancestor components, their appropriate receiveSignal() methods are called. If there are no listeners, the runtime cost is usually minimal.

◆ emit() [3/18]

virtual void emit ( simsignal_t signalID,
const SimTime & t,
cObject * details = nullptr )
virtual

Emits the simtime_t value as a signal. If the given signal has listeners in this component or in ancestor components, their appropriate receiveSignal() methods are called. If there are no listeners, the runtime cost is usually minimal.

◆ emit() [4/18]

virtual void emit ( simsignal_t signalID,
const char * s,
cObject * details = nullptr )
virtual

Emits the given string as a signal. Emitting nullptr is not allowed. If the given signal has listeners in this component or in ancestor components, their appropriate receiveSignal() methods are called. If there are no listeners, the runtime cost is usually minimal.

◆ emit() [5/18]

virtual void emit ( simsignal_t signalID,
cObject * obj,
cObject * details = nullptr )
virtual

Emits the given object as a signal. If the given signal has listeners in this component or in ancestor components, their appropriate receiveSignal() methods are called. If there are no listeners, the runtime cost is usually minimal.

◆ emit() [6/18]

virtual void emit ( simsignal_t signalID,
const cObject * obj,
cObject * details = nullptr )
inlinevirtual

Delegates to emit(simsignal_t, cObject*) after a const_cast.

References emit().

Referenced by emit().

◆ emit() [7/18]

virtual void emit ( simsignal_t signalID,
char c,
cObject * details = nullptr )
inlinevirtual

Emits the given integer as intval_t. See other emit methods, e.g. emit(simsignal_t,double,cObject*), for more information.

◆ emit() [8/18]

virtual void emit ( simsignal_t signalID,
unsigned char c,
cObject * details = nullptr )
inlinevirtual

Emits the given integer as uintval_t. See other emit methods, e.g. emit(simsignal_t,double,cObject*), for more information.

◆ emit() [9/18]

virtual void emit ( simsignal_t signalID,
short i,
cObject * details = nullptr )
inlinevirtual

Emits the given integer as intval_t. See other emit methods, e.g. emit(simsignal_t,double,cObject*), for more information.

◆ emit() [10/18]

virtual void emit ( simsignal_t signalID,
unsigned short i,
cObject * details = nullptr )
inlinevirtual

Emits the given integer as uintval_t. See other emit methods, e.g. emit(simsignal_t,double,cObject*), for more information.

◆ emit() [11/18]

virtual void emit ( simsignal_t signalID,
int i,
cObject * details = nullptr )
inlinevirtual

Emits the given integer as intval_t. See other emit methods, e.g. emit(simsignal_t,double,cObject*), for more information.

◆ emit() [12/18]

virtual void emit ( simsignal_t signalID,
unsigned int i,
cObject * details = nullptr )
inlinevirtual

Emits the given integer as uintval_t. See other emit methods, e.g. emit(simsignal_t,double,cObject*), for more information.

◆ emit() [13/18]

virtual void emit ( simsignal_t signalID,
long i,
cObject * details = nullptr )
inlinevirtual

Emits the given integer as intval_t. See other emit methods, e.g. emit(simsignal_t,double,cObject*), for more information.

◆ emit() [14/18]

virtual void emit ( simsignal_t signalID,
unsigned long i,
cObject * details = nullptr )
inlinevirtual

Emits the given integer as uintval_t. See other emit methods, e.g. emit(simsignal_t,double,cObject*), for more information.

◆ emit() [15/18]

virtual void emit ( simsignal_t signalID,
long long i,
cObject * details = nullptr )
inlinevirtual

Emits the given integer as intval_t. See other emit methods, e.g. emit(simsignal_t,double,cObject*), for more information.

◆ emit() [16/18]

virtual void emit ( simsignal_t signalID,
unsigned long long i,
cObject * details = nullptr )
inlinevirtual

Emits the given integer as uintval_t. See other emit methods, e.g. emit(simsignal_t,double,cObject*), for more information.

◆ emit() [17/18]

virtual void emit ( simsignal_t signalID,
float f,
cObject * details = nullptr )
inlinevirtual

Delegates to emit(simsignal_t, double)

References emit().

Referenced by emit().

◆ emit() [18/18]

virtual void emit ( simsignal_t signalID,
long double d,
cObject * details = nullptr )
inlinevirtual

Delegates to doEmit(simsignal_t, double)

References emit().

Referenced by emit().

◆ mayHaveListeners()

bool mayHaveListeners ( simsignal_t signalID) const
inline

If producing a value for a signal has a significant runtime cost, this method can be used to check beforehand whether the given signal possibly has any listeners at all. if not, emitting the signal can be skipped. This method has a constant cost but may return false positive.

◆ hasListeners()

bool hasListeners ( simsignal_t signalID) const

Returns true if the given signal has any listeners. In the current implementation, this involves checking listener lists in ancestor modules until the first listener is found, or up to the root. This method may be useful if producing the data for an emit() call would be expensive compared to a hasListeners() call.

See also
mayHaveListeners()

◆ subscribe() [1/2]

virtual void subscribe ( simsignal_t signalID,
cIListener * listener )
virtual

Adds a listener (callback object) that will be notified when a given signal is emitted (see emit() methods). It is an error to subscribe the same listener twice to the same signal. The order in which listeners will be notified is undefined, so it is not necessarily the same order in which listeners were subscribed.

◆ subscribe() [2/2]

virtual void subscribe ( const char * signalName,
cIListener * listener )
virtual

Convenience method; it is equivalent to subscribe(registerSignal(signalName), listener).

◆ unsubscribe() [1/2]

virtual void unsubscribe ( simsignal_t signalID,
cIListener * listener )
virtual

Removes the given listener. It has no effect if the given listener is not subscribed.

◆ unsubscribe() [2/2]

virtual void unsubscribe ( const char * signalName,
cIListener * listener )
virtual

Convenience method; it is equivalent to unsubscribe(registerSignal(signalName), listener).

◆ isSubscribed() [1/2]

virtual bool isSubscribed ( simsignal_t signalID,
cIListener * listener ) const
virtual

Returns true if the given listener is subscribed to the given signal at this component (i.e. it does not look at listeners subscribed at ancestor components).

◆ isSubscribed() [2/2]

virtual bool isSubscribed ( const char * signalName,
cIListener * listener ) const
virtual

Convenience method; it is equivalent to isSubscribed(registerSignal(signalName), listener).

◆ getLocalListenedSignals()

virtual std::vector< simsignal_t > getLocalListenedSignals ( ) const
virtual

Returns the signals which have listeners subscribed at this component.

◆ getLocalSignalListeners()

virtual std::vector< cIListener * > getLocalSignalListeners ( simsignal_t signalID) const
virtual

Returns the listeners subscribed to the given signal at this component.

◆ hasGUI()

virtual bool hasGUI ( ) const
virtual

Returns true if the current environment is a graphical user interface. (For example, it returns true if the simulation is running in Qtenv, and false if it's running over Cmdenv.) Modules can examine this flag to decide whether or not they need to bother with visualization, e.g. dynamically update display strings or draw on canvases.

This method delegates to cEnvir::isGUI().

◆ getDisplayString()

virtual cDisplayString & getDisplayString ( ) const
virtual

Returns the display string which defines presentation when the module is displayed as a submodule in a compound module graphics.

◆ setDisplayString()

virtual void setDisplayString ( const char * dispstr)
virtual

Shortcut to getDisplayString().set(dispstr).

◆ bubble()

virtual void bubble ( const char * text) const
virtual

When the models is running in Qtenv, it displays the given text in the network graphics, as a bubble above the module's icon.

◆ resolveResourcePath()

virtual std::string resolveResourcePath ( const char * fileName) const
virtual

Searches a number of folders for a resource given with its file name or relative path, and returns the path for the first match. If the resource is not found, the empty string is returned.

The list of the search folders includes the current working directory, the folder of the main ini file, the folder this component's NED file was loaded from, folders in the NED path, and folders in the image path (OMNETPP_IMAGE_PATH).

See also
cEnvir::resolveResourcePath()

◆ recordScalar() [1/2]

virtual void recordScalar ( const char * name,
double value,
const char * unit = nullptr )
virtual

Records a double into the scalar result file.

◆ recordScalar() [2/2]

virtual void recordScalar ( const char * name,
SimTime value,
const char * unit = nullptr )
inlinevirtual

Convenience method, delegates to recordScalar(const char *, double).

References SimTime::dbl(), and recordScalar().

Referenced by recordScalar().

◆ recordStatistic() [1/2]

virtual void recordStatistic ( cStatistic * stats,
const char * unit = nullptr )
virtual

Records the given statistics into the scalar result file. Delegates to cStatistic::recordAs(). Note that if the statistics object is a histogram, this operation may invoke its transform() method.

◆ recordStatistic() [2/2]

virtual void recordStatistic ( const char * name,
cStatistic * stats,
const char * unit = nullptr )
virtual

Records the given statistics into the scalar result file with the given name. Delegates to cStatistic::recordAs(). Note that if the statistics object is a histogram, this operation may invoke its transform() method.