OMNeT++ API 6.1
Discrete Event Simulation Library
Registration Macros

Description

Macros for registering various classes, functions and other extension items with the simulation kernel. Registration is necessary for allowing instantiation by class name and attaching meta-information.

Macros

#define Register_ResultFilter(NAME, CLASSNAME)
 Registers a result filter. More...
 
#define Register_ResultFilter2(NAME, CLASSNAME, DESCRIPTION)
 Registers a result filter with a description string. More...
 
#define Register_ResultRecorder(NAME, CLASSNAME)
 Registers a result recorder class. More...
 
#define Register_ResultRecorder2(NAME, CLASSNAME, DESCRIPTION)
 Registers a result recorder class with a description string. More...
 
#define Define_NED_Math_Function(NAME, ARGCOUNT)
 Registers a C/C++ mathematical function for use in NED and ini files. The function may take 0, 1, 2 or 3 double arguments, and must return a double. Corresponding C/C++ typedefs: MathFuncNoArg, MathFunc1Arg, MathFunc2Args, MathFunc3Args, MathFunc4Args. More...
 
#define Define_NED_Math_Function2(NAME, FUNCTION, ARGCOUNT)
 Like Define_NED_Math_Function(), but takes three arguments, the second one being the pointer to the function. This macro allows registering a function with a different name from its implementation. More...
 
#define Define_NED_Math_Function3(NAME, ARGCOUNT, CATEGORY, DESCRIPTION)
 Like Define_NED_Math_Function(), but takes category and description strings as well. More...
 
#define Define_NED_Math_Function4(NAME, FUNCTION, ARGCOUNT, CATEGORY, DESCRIPTION)
 Like Define_NED_Math_Function2(), but takes category and description strings as well. More...
 
#define Define_NED_Function(FUNCTION, SIGNATURE)
 Registers a C/C++ function for use in NED and ini files; see cNedFunction. FUNCTION is a pointer to the function, and SIGNATURE is the function's signature in NED. More...
 
#define Define_NED_Function2(FUNCTION, SIGNATURE, CATEGORY, DESCRIPTION)
 Like Define_NED_Function(), but allows one to specify a category string and documentation as well. More...
 
#define Register_Class(CLASSNAME)
 Register class. This defines a factory object which makes it possible to create an object by the passing class name to the createOne() function. The class must be a subclass of cObject, otherwise a compile-time error will occur: "cannot convert..." More...
 
#define Register_Abstract_Class(CLASSNAME)
 Register an abstract class. Registration makes it possible to dynamically test whether an object is a subclass of the registered class (see cObjectFactory::isInstance()). The class must be a subclass of cObject, otherwise a compile-time error will occur: "cannot convert..." More...
 
#define Define_Module(CLASSNAME)
 Announces the C++ simple module class to OMNeT++, and couples it with the NED simple module declaration of the same name. More...
 
#define Define_Channel(CLASSNAME)
 Announces the C++ channel class to OMNeT++, and couples it with the NED channel declaration of the same name. More...
 
#define Register_ClassDescriptor(DESCRIPTORCLASS)
 Internal. Registers a class descriptor which provides reflection information. More...
 
#define Register_GlobalConfigOption(ID, NAME, TYPE, DEFAULTVALUE, DESCRIPTION)
 Registers a global configuration option. More...
 
#define Register_PerRunConfigOption(ID, NAME, TYPE, DEFAULTVALUE, DESCRIPTION)
 Registers a per-run configuration option. More...
 
#define Register_GlobalConfigOptionU(ID, NAME, UNIT, DEFAULTVALUE, DESCRIPTION)
 Registers a global configuration option with type==CFG_DOUBLE and an expected unit of measurement. More...
 
#define Register_PerRunConfigOptionU(ID, NAME, UNIT, DEFAULTVALUE, DESCRIPTION)
 Registers a per-run configuration option with type==CFG_DOUBLE and an expected unit of measurement. More...
 
#define Register_PerObjectConfigOption(ID, NAME, KIND, TYPE, DEFAULTVALUE, DESCRIPTION)
 Registers a per-object configuration option. More...
 
#define Register_PerObjectConfigOptionU(ID, NAME, KIND, UNIT, DEFAULTVALUE, DESCRIPTION)
 Registers a per-object configuration option with type==CFG_DOUBLE and an expected unit of measurement. More...
 
#define Register_MessagePrinter(CLASSNAME)
 Registers a message printer class (cMessagePrinter) More...
 
#define Register_Enum(NAME, VALUES)
 Registers an enum. More...
 
#define Register_Enum2(VAR, NAMESTR, VALUES)
 Registers an enum, and makes it accessible via a global cEnum* pointer, using explicit strings for the enum type and it member names. More...
 
#define Register_Enum_WithVar(VAR, NAME, VALUES)
 Registers an enum while giving access to the resulting cEnum object (Its pointer will be stored in the cEnum* variable given as the first argument). More...
 
#define Register_Enum_Custom(VAR, NAME, NAME_VALUE_PAIRS)
 Registers an enum and makes it accessible via a global cEnum* pointer, allowing custom names for enum members. More...
 
#define Register_Figure(NAME, CLASSNAME)
 Registers a new figure type. The macro expects a type name string (an identifier that can be used in the type attribute of the @figure property), and a C++ class name. The class must be derived from cFigure. More...
 

Macro Definition Documentation

◆ Register_ResultFilter

#define Register_ResultFilter (   NAME,
  CLASSNAME 
)

Registers a result filter.

The class must be a subclass of cResultFilter. Registered result filters can be used in the source= and record= attributes of @statistic properties in NED files, and with the **.result-recording-modes= configuration option.

See also
Result Filters and Recorders

◆ Register_ResultFilter2

#define Register_ResultFilter2 (   NAME,
  CLASSNAME,
  DESCRIPTION 
)

Registers a result filter with a description string.

The class must be a subclass of cResultFilter. Registered result filters can be used in the source= and record= attributes of @statistic properties in NED files, and with the **.result-recording-modes= configuration option.

See also
Result Filters and Recorders

◆ Register_ResultRecorder

#define Register_ResultRecorder (   NAME,
  CLASSNAME 
)

Registers a result recorder class.

The class must be a subclass of cResultRecorder.

Registered result recorders can be used in the record= attributes of @statistic properties in NED files, and with the **.result-recording-modes= configuration option.

See also
Result Filters and Recorders

◆ Register_ResultRecorder2

#define Register_ResultRecorder2 (   NAME,
  CLASSNAME,
  DESCRIPTION 
)

Registers a result recorder class with a description string.

The class must be a subclass of cResultRecorder.

Registered result recorders can be used in the record= attributes of @statistic properties in NED files, and with the **.result-recording-modes= configuration option.

See also
Result Filters and Recorders

◆ Define_NED_Math_Function

#define Define_NED_Math_Function (   NAME,
  ARGCOUNT 
)

Registers a C/C++ mathematical function for use in NED and ini files. The function may take 0, 1, 2 or 3 double arguments, and must return a double. Corresponding C/C++ typedefs: MathFuncNoArg, MathFunc1Arg, MathFunc2Args, MathFunc3Args, MathFunc4Args.

Commonly used <math.h> functions have Define_NED_Math_Function() lines in the OMNeT++ simulation kernel.

See also
Define_NED_Function

◆ Define_NED_Math_Function2

#define Define_NED_Math_Function2 (   NAME,
  FUNCTION,
  ARGCOUNT 
)

Like Define_NED_Math_Function(), but takes three arguments, the second one being the pointer to the function. This macro allows registering a function with a different name from its implementation.

◆ Define_NED_Math_Function3

#define Define_NED_Math_Function3 (   NAME,
  ARGCOUNT,
  CATEGORY,
  DESCRIPTION 
)

Like Define_NED_Math_Function(), but takes category and description strings as well.

◆ Define_NED_Math_Function4

#define Define_NED_Math_Function4 (   NAME,
  FUNCTION,
  ARGCOUNT,
  CATEGORY,
  DESCRIPTION 
)

Like Define_NED_Math_Function2(), but takes category and description strings as well.

◆ Define_NED_Function

#define Define_NED_Function (   FUNCTION,
  SIGNATURE 
)

Registers a C/C++ function for use in NED and ini files; see cNedFunction. FUNCTION is a pointer to the function, and SIGNATURE is the function's signature in NED.

The C++ function can have either of the following two signatures:

cValue f(cComponent *context, cValue argv[], int argc);  // typedef NedFunction
cValue f(cExpression::Context *context, cValue argv[], int argc);  // typedef NedFunctionExt

SIGNATURE is a string with the following syntax: returntype functionname(argtype1 argname1, ...), where a type can be one of 'bool', 'int', 'double', 'quantity' ('double' with measurement unit), 'string', 'xml' and 'any'. Optional arguments are denoted by appending a '?' to their names. To let the function accept any number of additional arguments of arbitrary types, add ',...' to the signature.

Example:

Define_NED_Function(uniformFunc,"quantity uniform(quantity a, quantity b, long rng?)")

◆ Define_NED_Function2

#define Define_NED_Function2 (   FUNCTION,
  SIGNATURE,
  CATEGORY,
  DESCRIPTION 
)

Like Define_NED_Function(), but allows one to specify a category string and documentation as well.

◆ Register_Class

#define Register_Class (   CLASSNAME)

Register class. This defines a factory object which makes it possible to create an object by the passing class name to the createOne() function. The class must be a subclass of cObject, otherwise a compile-time error will occur: "cannot convert..."

See also
cObjectFactory, cObjectFactory::createOne(), cObjectFactory::isInstance()

◆ Register_Abstract_Class

#define Register_Abstract_Class (   CLASSNAME)

Register an abstract class. Registration makes it possible to dynamically test whether an object is a subclass of the registered class (see cObjectFactory::isInstance()). The class must be a subclass of cObject, otherwise a compile-time error will occur: "cannot convert..."

See also
cObjectFactory, cObjectFactory::isInstance()

◆ Define_Module

#define Define_Module (   CLASSNAME)

Announces the C++ simple module class to OMNeT++, and couples it with the NED simple module declaration of the same name.

◆ Define_Channel

#define Define_Channel (   CLASSNAME)

Announces the C++ channel class to OMNeT++, and couples it with the NED channel declaration of the same name.

◆ Register_ClassDescriptor

#define Register_ClassDescriptor (   DESCRIPTORCLASS)

Internal. Registers a class descriptor which provides reflection information.

◆ Register_GlobalConfigOption

#define Register_GlobalConfigOption (   ID,
  NAME,
  TYPE,
  DEFAULTVALUE,
  DESCRIPTION 
)

Registers a global configuration option.

◆ Register_PerRunConfigOption

#define Register_PerRunConfigOption (   ID,
  NAME,
  TYPE,
  DEFAULTVALUE,
  DESCRIPTION 
)

Registers a per-run configuration option.

◆ Register_GlobalConfigOptionU

#define Register_GlobalConfigOptionU (   ID,
  NAME,
  UNIT,
  DEFAULTVALUE,
  DESCRIPTION 
)

Registers a global configuration option with type==CFG_DOUBLE and an expected unit of measurement.

◆ Register_PerRunConfigOptionU

#define Register_PerRunConfigOptionU (   ID,
  NAME,
  UNIT,
  DEFAULTVALUE,
  DESCRIPTION 
)

Registers a per-run configuration option with type==CFG_DOUBLE and an expected unit of measurement.

◆ Register_PerObjectConfigOption

#define Register_PerObjectConfigOption (   ID,
  NAME,
  KIND,
  TYPE,
  DEFAULTVALUE,
  DESCRIPTION 
)

Registers a per-object configuration option.

◆ Register_PerObjectConfigOptionU

#define Register_PerObjectConfigOptionU (   ID,
  NAME,
  KIND,
  UNIT,
  DEFAULTVALUE,
  DESCRIPTION 
)

Registers a per-object configuration option with type==CFG_DOUBLE and an expected unit of measurement.

◆ Register_MessagePrinter

#define Register_MessagePrinter (   CLASSNAME)

Registers a message printer class (cMessagePrinter)

◆ Register_Enum

#define Register_Enum (   NAME,
  VALUES 
)

Registers an enum.

Example:

enum State { STATE_IDLE, STATE_BUSY, STATE_SLEEPING };
Register_Enum(State, (STATE_IDLE, STATE_BUSY, STATE_SLEEPING));
enum class Mode { ACTIVE, PASSIVE, AUTO };
Register_Enum(Mode, (Mode::ACTIVE, Mode::PASSIVE, Mode::AUTO));
See also
cEnum

◆ Register_Enum2

#define Register_Enum2 (   VAR,
  NAMESTR,
  VALUES 
)

Registers an enum, and makes it accessible via a global cEnum* pointer, using explicit strings for the enum type and it member names.

NOTE: This macro is deprecated – use Register_Enum_Custom() instead!

Example:

enum State { IDLE, BUSY, SLEEPING };
Register_Enum2(stateEnum, "State", (
   "idle",     State::IDLE,
   "busy",     State::BUSY,
   "sleeping", State::SLEEPING,
   nullptr)); // see note below
See also
cEnum

◆ Register_Enum_WithVar

#define Register_Enum_WithVar (   VAR,
  NAME,
  VALUES 
)

Registers an enum while giving access to the resulting cEnum object (Its pointer will be stored in the cEnum* variable given as the first argument).

Example:

enum State { IDLE, BUSY, SLEEPING };
Register_Enum_WithVar(stateEnum, State, (IDLE, BUSY, SLEEPING));
enum class Mode { ACTIVE, PASSIVE, AUTO };
Register_Enum_WithVar(modeEnum, Mode, (Mode::ACTIVE, Mode::PASSIVE, Mode::AUTO));
See also
cEnum

◆ Register_Enum_Custom

#define Register_Enum_Custom (   VAR,
  NAME,
  NAME_VALUE_PAIRS 
)

Registers an enum and makes it accessible via a global cEnum* pointer, allowing custom names for enum members.

Example:

enum State { STATE_IDLE, STATE_BUSY, STATE_SLEEPING };
Register_Enum_Custom(stateEnum, State, (
   { "idle",     STATE_IDLE },
   { "busy",     STATE_BUSY },
   { "sleeping", STATE_SLEEPING }
)
See also
cEnum

◆ Register_Figure

#define Register_Figure (   NAME,
  CLASSNAME 
)

Registers a new figure type. The macro expects a type name string (an identifier that can be used in the type attribute of the @figure property), and a C++ class name. The class must be derived from cFigure.

Note: Register_Figure() includes registration the figure class via a Register_Class().

Example:

Register_Figure("polyline", cPolylineFigure);