OMNeT++ Simulation Library  6.0.3
cModuleType Class Referenceabstract

#include <ccomponenttype.h>

Description

Abstract class for creating a module of a specific type.

A cModuleType object exist for each module type (simple or compound).

Inheritance diagram for cModuleType:
cComponentType cNoncopyableOwnedObject cOwnedObject noncopyable cNamedObject cObject

Public Member Functions

Constructors, destructor, assignment
 cModuleType (const char *qname=nullptr)
 
Misc
virtual bool isNetwork () const =0
 
virtual bool isSimple () const =0
 
- Public Member Functions inherited from cComponentType
 cComponentType (const char *qname=nullptr)
 
virtual ~cComponentType ()
 
virtual const char * getFullName () const override
 
virtual std::string getNedSource () const =0
 
- 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 std::string getFullPath () const
 
virtual std::string getClassAndFullName () const
 
virtual std::string getClassAndFullPath () const
 
const cObjectgetThisPtr () const
 
virtual std::string str () const
 
virtual std::ostream & printOn (std::ostream &os) const
 
virtual bool isSoftOwner () const
 
virtual void forEachChild (cVisitor *v)
 
cObjectfindObject (const char *name, bool deep=true)
 
virtual cClassDescriptorgetDescriptor () const
 
void copyNotSupported () const
 

Module creation

virtual cModulecreate (const char *name, cModule *parentmod, int index=-1)
 
virtual cModulecreateScheduleInit (const char *name, cModule *parentmod, int index=-1)
 
static cModuleTypefind (const char *qname)
 
static cModuleTypeget (const char *qname)
 

Additional Inherited Members

- Static Public Member Functions inherited from cComponentType
static cComponentTypefind (const char *qname)
 
static cComponentTypeget (const char *qname)
 
- Static Public Member Functions inherited from cOwnedObject
static long getTotalObjectCount ()
 
static long getLiveObjectCount ()
 
static void resetObjectCounters ()
 
static cSoftOwnergetOwningContext ()
 
- Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
 
virtual void drop (cOwnedObject *obj)
 
void dropAndDelete (cOwnedObject *obj)
 

Constructor & Destructor Documentation

◆ cModuleType()

cModuleType ( const char *  qname = nullptr)

Constructor.

Member Function Documentation

◆ isNetwork()

virtual bool isNetwork ( ) const
pure virtual

Returns true if the module type was declared with the "network" keyword.

◆ isSimple()

virtual bool isSimple ( ) const
pure virtual

Returns true if this module type was declared as a simple module in the NED file, i.e. using the "simple" keyword.

◆ create()

virtual cModule* create ( const char *  name,
cModule parentmod,
int  index = -1 
)
virtual

Creates a submodule under the given parent module. If index is given, the module creates an element in a module vector; the module vector of the given name must already exist and must be sufficiently large (size>index).

In addition to creating an object of the correct type, this function inserts the module into the simulation's data structure, and adds the parameters and gates specified in the NED declaration.

After creation, the module still needs to go through a setup of several steps before it is ready to use. The full process is the following:

cModule *module = create("foo", parentModule);
[set parameters]
module->finalizeParameters();
[connect gates]
module->buildInside();
module->scheduleStart(simTime());
module->callInitialize();

As callInitialize() and some of the other functions perform the preceding steps if they are not yet done, the above code can be abbreviated to:

cModule *module = create("foo", parentModule);
[set parameters]
module->callInitialize();

◆ createScheduleInit()

virtual cModule* createScheduleInit ( const char *  name,
cModule parentmod,
int  index = -1 
)
virtual

This is a convenience function to get a module up and running in one step.

First, the module is created using create() and buildInside(), then a starter message is created (for activity() modules only), then initialize() is called (mod->callInitialize()).

This method works for simple and compound modules alike. Not applicable if the module:

  • has parameters to be set
  • gate vector sizes to be set
  • gates to be connected before initialize()

◆ find()

static cModuleType* find ( const char *  qname)
static

Finds a module type by fully qualified NED type name. Returns nullptr if not found.

◆ get()

static cModuleType* get ( const char *  qname)
static

Finds a module type by fully qualified NED type name. Throws an error if not found.


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