Abstract class for creating a module of a specific type. More...
#include <ccomponenttype.h>
Public Member Functions | |
Constructors, destructor, assignment | |
cModuleType (const char *qname=NULL) | |
Misc | |
virtual bool | isNetwork () const =0 |
virtual bool | isSimple () const =0 |
Module creation | |
virtual cModule * | create (const char *name, cModule *parentmod) |
virtual cModule * | create (const char *name, cModule *parentmod, int vectorsize, int index) |
virtual cModule * | createScheduleInit (const char *name, cModule *parentmod) |
Static Public Member Functions | |
static cModuleType * | find (const char *qname) |
static cModuleType * | get (const char *qname) |
Protected Member Functions | |
virtual cModule * | createModuleObject ()=0 |
virtual void | addParametersAndGatesTo (cModule *mod)=0 |
virtual void | setupGateVectors (cModule *mod)=0 |
virtual void | buildInside (cModule *mod)=0 |
cModule * | instantiateModuleClass (const char *classname) |
Friends | |
class | cModule |
Abstract class for creating a module of a specific type.
A cModuleType object exist for each module type (simple or compound).
virtual void cModuleType::addParametersAndGatesTo | ( | cModule * | mod | ) | [protected, pure virtual] |
Adds parameters and gates to a newly created module object.
Gate vectors will be created with zero size, and a further call to setupGateVectors() will be needed once parameter values have been finalized.
virtual void cModuleType::buildInside | ( | cModule * | mod | ) | [protected, pure virtual] |
Creates and connects submodules of a newly created module object.
To be defined in subclasses. addParametersAndGatesTo() and setupGateVectors() must have been already called at this point.
NOTE: If you have an old simulation model that attempts to call this method directly, it is using an API call which has been DEPRECATED since OMNeT++ 2.3b1 -- please change the code to mod->buildInside()
.
virtual cModule* cModuleType::create | ( | const char * | name, | |
cModule * | parentmod, | |||
int | vectorsize, | |||
int | index | |||
) | [virtual] |
Creates a module to be an element of a module vector.
The last two arguments specify the vector size and the index of the new module within the vector.
Creates a module which is not element of a module vector.
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.
virtual cModule* cModuleType::createModuleObject | ( | ) | [protected, pure virtual] |
Creates the module object.
To be defined in subclasses.
virtual cModule* cModuleType::createScheduleInit | ( | const char * | name, | |
cModule * | parentmod | |||
) | [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:
static cModuleType* cModuleType::find | ( | const char * | qname | ) | [static] |
Finds a module type by fully qualified NED type name.
Returns NULL if not found.
Reimplemented from cComponentType.
static cModuleType* cModuleType::get | ( | const char * | qname | ) | [static] |
Finds a module type by fully qualified NED type name.
Throws an error if not found.
Reimplemented from cComponentType.
cModule* cModuleType::instantiateModuleClass | ( | const char * | classname | ) | [protected] |
Utility function: instantiates the given class, and tries to cast the result to cModule.
Raises an error if class was not found or could not be cast.
virtual void cModuleType::setupGateVectors | ( | cModule * | mod | ) | [protected, pure virtual] |
Sets gate vector sizes on the module.
This must be called AFTER all parameters have been set (see finalizeParameters()) because gate vector sizes may depend on parameter values; and it it must be invoked before connecting the gates and calling mod->buildInside().