Main Page Modules Class Hierarchy Compound List File List Compound Members

# cModuleType Class Reference

`#include <ctypes.h>`

Inheritance diagram for cModuleType::

List of all members.

## Public Methods

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 cObject* | dup () const
Module creation
cModule* | create (const char *name, cModule *parentmod, bool local=true)
void | buildInside (cModule *mod)
cModule* | createScheduleInit (char *name, cModule *parentmod)
cModuleInterface* | moduleInterface ()

## 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 );

nedc automatically generates Define_Module for compound modules, but the user is responsible for writing it for each simple module type.

## Constructor & Destructor Documentation

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

| Constructor.

cModuleType::cModuleType ( | const cModuleType & mi )

| Copy constructor.

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

| Destructor.

## Member Function Documentation

void cModuleType::buildInside ( | cModule * mod )

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

cModule * cModuleType::create ( | const char * name,
| cModule * parentmod,
| bool local = true )

| Creates a module. 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.

cModule * cModuleType::createScheduleInit ( | char * name,
| cModule * parentmod )

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

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

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

cModuleInterface * cModuleType::moduleInterface ( | )

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