Overview

All components should take the form of a class definition file that defines a class derived from one of the component base classes (described below). The name of the class should be exactly the Class Name of the component, with the slashes replaced by underscores, followed by an additional underscore, followed by the release number in numerals. For example, the current numeric data component has class name std_2009_data_numeric_0.

Classes

The base classes of all three component types are the same, except that the Process base class has two instances of SystemMLInterface representing its input and output interfaces, as follows.

C++ API (1199)
class Data, Process, Utility { public: virtual Symbol event(Event* event) = 0; const ComponentTime* time; Symbol hComponent; ComponentOut bout; #ifdef COMPONENT_PROCESS SystemMLInterface iif; SystemMLInterface oif; #endif };

Your derived class must define the virtual event() function, and perform all its processing within this function. The member variables have the following significance.

const ComponentTime* time
Pointer to the time object for this component (which is maintained by the framework). You can dereference it using time-> to read your timing data.
Symbol hComponent
The Handle of this component. Should be passed to Component Interface functions which require hCaller (handle of the caller).
ComponentOut bout
The Component's output object, which is connected to the BRAHMS Structured Log. Any messages for the user should be sent through this object.
SystemMLInterface iif
SystemML input interface.
SystemMLInterface oif
SystemML output interface.

Extras

If you #define MODULE_SHOW_EVENTS, entry and exit from each event will be dumped to stdout. If you #define MODULE_INIT_TERM, the binding will call two functions, declared below, on receiving EVENT_MODULE_INIT and EVENT_MODULE_TERM (allowing you to supply custom code to init/term your module). The return values from these functions are used as the return values from the events.

C++ Source Code (against 1199)
Symbol result = moduleInit(EventModuleInit* init); Symbol result = moduleTerm(EventModuleTerm* init);

Example

Taken from std/source/numeric.

C++ Source Code (against 1199)
// component information #define COMPONENT_CLASS_STRING "std/2009/source/numeric" #define COMPONENT_CLASS_CPP std_2009_source_numeric_0 #define COMPONENT_FLAGS F_NOT_RATE_CHANGER ... // include once #include "brahms-1199.h" // component class class COMPONENT_CLASS_CPP : public Process { public: // use ctor/dtor if required COMPONENT_CLASS_CPP(); ~COMPONENT_CLASS_CPP(); // framework event function Symbol event(Event* event); private: // my data INT32 data; ... }; // event function Symbol COMPONENT_CLASS_CPP::event(Event* event) { switch(event->type) { case EVENT_RUN_SERVICE: { ... } ... } // not serviced return S_NULL; } // include twice #include "brahms-1199.h"