# cModuleInterface Class Reference
[Internal classes]

`#include <ctypes.h>`

Inheritance diagram for cModuleInterface:

List of all members.

## Detailed Description

Describes the interface (modules, gates,.

..) of a module type. cModuleInterfaces are used during network setup (and dynamic module creation) to add gates and parameters to the freshly created module object, and also to verify that module parameters set correctly.

cModuleInterfaces may be created either dynamically or by the NED compiler. In the latter case, the are the compiled form of NED declarations of simple modules. They are created in the following way:

1) starting point is the NED declarations of simple modules, e.g:

            simple Generator
              parameters: ia_rate;
              gates: out: out;
            endsimple

2) the nedtool compiler translates the NED declaration into a ModuleInterface...End macro and places it into the _n.cc file.

            ModuleInterface(Generator)
              Parameter("speed", Numeric)
              Gate( "out", Output)
            EndInterface

The above translates into cModuleInterface::DeclarationItem array by means of define macros.

3) When the program starts up, cModuleInterfaces are registered, and cModuleInterface constructor parses the array into an internal data structure.

4) When a module is created, the appropriate cModuleInterface object is looked up from the list, and the module's gates and parameters are created according to the description in the cModuleInterface object.

## Public Member Functions

Constructors, destructor, assignment
| cModuleInterface (const char *name)
| cModuleInterface (const char *name, DeclarationItem *decltable)
| cModuleInterface (const cModuleInterface &mi)
virtual | ~cModuleInterface ()
cModuleInterface & | operator= (const cModuleInterface &mi)
Redefined cObject member functions.
virtual cPolymorphic * | dup () const
Setting up a module interface manually
void | allocateGateDecls (int maxnumgates)
void | allocateParamDecls (int maxnumparams)
void | addGateDecl (const char *name, const char type, bool isvector=false)
void | addParamDecl (const char *name, const char *types)
Query on the module interface
int | numParams ()
int | findParam (const char *name)
const char * | paramName (int k)
const char * | paramType (int k)
bool | isParamConst (int k)
int | numGates ()
int | findGate (const char *name)
const char * | gateName (int k)
char | gateType (int k)
bool | isGateVector (int k)
Applying the interface to modules.
void | addParametersGatesTo (cModule *module)
void | checkParametersOf (cModule *module)

## Constructor & Destructor Documentation

cModuleInterface::cModuleInterface | ( | const char * | name | ) |

| Constructor.

cModuleInterface::cModuleInterface | ( | const char * | name,
|  | DeclarationItem * | decltable
| ) |

| Constructor.

cModuleInterface::cModuleInterface | ( | const cModuleInterface & | mi | ) |

| Copy constructor.

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

| Destructor.

## Member Function Documentation

void cModuleInterface::addGateDecl | ( | const char * | name,
|  | const char | type,
|  | bool | isvector = `false`
| ) |

| Add a gate declaration.

void cModuleInterface::addParamDecl | ( | const char * | name,
|  | const char * | types
| ) |

| Add a parameter declaration.

void cModuleInterface::addParametersGatesTo | ( | cModule * | module | ) |

| Adds parameters and gates specified by the interface to the given module.

void cModuleInterface::allocateGateDecls | ( | int | maxnumgates | ) |

| Make room for a given number of gate declarations.

void cModuleInterface::allocateParamDecls | ( | int | maxnumparams | ) |

| Make room for a given number of parameter declarations.

void cModuleInterface::checkParametersOf | ( | cModule * | module | ) |

| Checks that the types of the module's parameters comply to the interface, and calls convertToConst() on the parameters declared as const in the interface.

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

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

int cModuleInterface::findGate | ( | const char * | name | ) |

| Returns index of the given gate (0. .numGates()), or -1 if not found

int cModuleInterface::findParam | ( | const char * | name | ) |

| Returns index of the given param (0. .numParams()), or -1 if not found

const char* cModuleInterface::gateName | ( | int | k | ) |

| Returns the name of the kth gate.

char cModuleInterface::gateType | ( | int | k | ) |

| Returns if the kth gate is input or output.

bool cModuleInterface::isGateVector | ( | int | k | ) |

| Returns if the kth gate is a gate vector.

bool cModuleInterface::isParamConst | ( | int | k | ) |

| Returns if the kth parameter is declarared to be `const`.

int cModuleInterface::numGates | ( |  | ) |

| Returns the number of gates.

int cModuleInterface::numParams | ( |  | ) |

| Returns the number of parameters.

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

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

const char* cModuleInterface::paramName | ( | int | k | ) |

| Returns the name of the kth parameter.

const char* cModuleInterface::paramType | ( | int | k | ) |

| Returns the cPar types allowed for the kth parameter.

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

- ctypes.h