# cModuleType Class Reference
[Internal classes]

`#include <ctypes.h>`

Inheritance diagram for cModuleType:

List of all members.

## Detailed Description

Class for creating a module of a specific type.

A cModuleType object exist for each module type (simple or compound). A cModuleType object 'knows' how to create a module of a given type, thus a module can be created without having to include the .h file with the C++ declaration of the module class ("class FddiMAC..."). A cModuleType object is created through a Define_Module macro. Thus, each module type must have a Define_Module() line, e.g:

Define_Module( MySimpleModule );

nedtool automatically generates Define_Module for compound modules, but the user is responsible for adding one for each simple module type.

## Public Member Functions

Constructors, destructor, assignment
| cModuleType (const char *classname, const char *interf_name, ModuleCreateFunc cf)
| cModuleType (const cModuleType &mi)
virtual | ~cModuleType ()
cModuleType & | operator= (const cModuleType &mi)
Redefined cObject member functions.
virtual cPolymorphic * | dup () const
Module creation
virtual cModule * | create (const char *name, cModule *parentmod)
virtual cModule * | create (const char *name, cModule *parentmod, int vectorsize, int index)
virtual void | buildInside (cModule *mod)
virtual cModule * | createScheduleInit (char *name, cModule *parentmod)
virtual cModuleInterface * | moduleInterface ()

## Friends

class | cModule

## Constructor & Destructor Documentation

cModuleType::cModuleType | ( | const char * | classname,
|  | const char * | interf_name,
|  | ModuleCreateFunc | cf
| ) |

| Constructor.

cModuleType::cModuleType | ( | const cModuleType & | mi | ) |

| Copy constructor.

virtual cModuleType::~cModuleType | ( |  | ) | `[virtual]`

| Destructor.

## Member Function Documentation

virtual void cModuleType::buildInside | ( | cModule * | mod | ) | `[virtual]`

| DEPRECATED. Use `mod->buildInside()` instead; that's what this method does anyway.

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.

virtual cModule* cModuleType::create | ( | const char * | name,
|  | cModule * | parentmod
| ) | `[virtual]`

| Creates a module which is not element of a module vector. In addition to creating an object of the correct type, this function inserts it into cSimulation's module vector and adds the parameters and gates specified in the interface description.

virtual cModule* cModuleType::createScheduleInit | ( | 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 starter messages are created (using mod->scheduleStart(simulation.simTime())), then initialize() is called (mod->callInitialize()). It is important that scheduleStart() be called before initialize(), because initialize() functions might contain scheduleAt() calls which could otherwise insert a message BEFORE the starter messages for module.

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

virtual cPolymorphic* cModuleType::dup | ( |  | ) | const`[inline, virtual]`

| Creates and returns an exact copy of this object. See cObject for more details. Reimplemented from cObject.

virtual cModuleInterface* cModuleType::moduleInterface | ( |  | ) | `[virtual]`

Returns pointer to the module interface object corresponding to this module type.

See also:
  cModuleInterface

cModuleType& cModuleType::operator= | ( | const cModuleType & | mi | ) |

| Assignment operator. The name member doesn't get copied; see cObject's operator=() for more details.

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

- ctypes.h