Main Page Modules Class Hierarchy Compound List File List Compound Members

# Macros

## FSM Macros
#define | FSM_MAXT 64
#define | FSM_Switch(fsm)
#define | FSM_Transient(state)
#define | FSM_Steady(state)
#define | FSM_Enter(state)
#define | FSM_Exit(state)
#define | FSM_Goto(fsm, state)
## Watches
#define | WATCH(var)
#define | LWATCH(var)
## Declaration macros
#define | Define_Network(NAME)
#define | Define_Link(NAME, DELAY, ERROR, DATARATE)
#define | Define_Function(NAME, ARGCOUNT)
#define | Define_Function2(NAME, FUNCTION, ARGCOUNT)
#define | Register_Class(CLASSNAME)
## Module declaration macros
#define | Define_Module(CLASSNAME)
#define | Define_Module_Like(CLASSNAME, INTERFACENAME)
#define | Module_Class_Members(CLASSNAME, BASECLASS, STACK)

## Define Documentation

#define Define_Function( | NAME, ARGCOUNT )

| Registers a mathematical function that takes 0, 1, 2 or 3 double arguments and returns a double. The use of this macro allows the function to be used in expressions inside NED network descriptions. Commonly used <math.h> functions have Define_Function() lines in the OMNeT++ simulation kernel.

#define Define_Function2( | NAME, FUNCTION, ARGCOUNT )

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

#define Define_Link( | NAME, DELAY, ERROR, DATARATE )

| Link type definition. The macro expands to the definition of a cLinkType object; the last three arguments are pointers to functions which dynamically create cPar objects an return their pointers.

#define Define_Module( | CLASSNAME )

| Announces the class as a module to OMNeT++ and couples it with the NED interface of the same name. The macro expands to the definition a cModuleType object. The NEDC compiler generates Define_Module() lines for all compound modules. However, it is the user's responsibility to put Define_Module() lines for all simple module types into one of the C++ sources.

#define Define_Module_Like( | CLASSNAME, INTERFACENAME )

| Similar to Define_Module(), except that it couples the class with the NED interface of the given name. This macro is used in connection with the 'like' phrase in NED.

#define Define_Network( | NAME )

| Network declaration macro. It can be found in code generated by the NEDC compiler. The use of this macro allows the creation of a network when only its name is available as a string. (Typically, the name of the network to be simulated is read from the configuration file.) The macro expands to the definition of a cNetworkType object.

#define FSM_Enter( | state )

| Within an FSM_Switch() case branch, declares code to be executed on entering the given state. No calls to FSM_Goto() are allowed within a state's Enter block. See also: FSM_Switch

#define FSM_Exit( | state )

| Within an FSM_Switch() case branch, declares code to be executed on exiting the given state. See also: FSM_Switch

#define FSM_Goto( | fsm, state )

| To be used in state exit code, to transition to another state. Uses stringize (state), so it only works correctly if 'state' is the enum name itself and not some variable that contains the state code. See also: FSM_Switch

#define FSM_MAXT 64

| After this many transitions without reaching a steady state we assume the FSM is in an infinite loop.

#define FSM_Steady( | state )

| Declares a steady state; to be used in enum which declares states. See example in FSM_Transient. See also: FSM_Transient, FSM_Switch

#define FSM_Switch( | fsm )

| Implements a Finite State Machine. FSM state is stored in an object of type cFSM. There are two kinds of states: transient and steady. At each execution of the FSM_Switch() statement, the FSM transitions out of the current (steady) state, potentially undergoes a series of state changes to transient states, and arrives at another steady state. The actual FSM is embedded in an FSM_Switch(), which has cases for entering and leaving each state:
     FSM_Switch(fsm)
     {
         case FSM_Exit(state1):
             //...
             break;
         case FSM_Enter(state1):
             //...
             break;
         case FSM_Exit(state2):
             //...
             break;
         case FSM_Enter(state2):
             //...
             break;
         //...
     }
States are declared in enums, using the FSM_Transient() and FSM_Steady() macros. State transitions are done via calls to FSM_Goto(), which simply stores the new state in the cFSM object. See also: cFSM, FSM_Transient, FSM_Steady, FSM_Goto, FSM_Debug, FSM_Print

#define FSM_Transient( | state )

| Declares a transient state; to be used in enum which declares states. Example:
     enum {
        INIT = 0,
        SLEEP = FSM_Steady(1),
        ACTIVE = FSM_Steady(2),
        SEND = FSM_Transient(1),
     };
The numbers in parens must be unique within the state type and they are used for constructing numeric IDs for the states. See also: FSM_Steady, FSM_Switch

#define LWATCH( | var )

| Like WATCH(), but may be executed more than once. See also: WATCH()

#define Module_Class_Members( | CLASSNAME, BASECLASS, STACK )

| This macro facilitates the declaration of a simple module class, and it expands to the definition of mandatory member functions. (Currently only a constructor.) The macro is used like this:
      class CLASSNAME : public cSimpleModule
      {
         Module_Class_Members(CLASSNAME,cSimpleModule,8192)
         virtual void activity();
      };

#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.

#define WATCH( | var )

| Enables int, long, double, char, etc. variables to be inspectable in Tkenv and to be included into the snapshot file. Example usage:
       int i;
       WATCH(i);
The WATCH() macro expands to a dynamically created cWatch object, like this:
       new cWatch("i",i);
The WATCH() macro must be executed exactly once for a variable, otherwise a new cWatch object is created every time. The alternative is LWATCH which works by creating a local variable. LWATCH expands to something like
       cWatch i__varshell("i",i);
See also: LWATCH()