Overview
C API (Component Interface)
struct EventModuleInit { const struct ExecutionInfo* executionInfo; const struct ModuleInfo* moduleInfo; };

The module should take a copy of the passed pointer to an execution information structure, and return a pointer to a module-level module information structure. Both pointers are (must be) valid for the lifetime of the module and may be read at any time.

Context

This event is the first event fired on a BRAHMS Module, and is an opportunity for the Module to initialise.

Notes
  • In contrast to all other events, EVENT_MODULE_INIT and EVENT_MODULE_TERM are fired only once on each loaded module - they are not fired for each component that the module instantiates.
  • In contrast to all other events, EVENT_MODULE_INIT and EVENT_MODULE_TERM are fired from the caller thread - they are not fired from the worker thread. They should perform no thread-specific, or instance-specific, operations.

Fields

ExecutionInfo* executionInfo IN
This is a pointer to an execution information structure. The pointer will remain valid for the lifetime of the module, and can be accessed at any time.
ModuleInfo* moduleInfo OUT
The module should return a pointer to a module information structure. This pointer must be valid for the lifetime of the module, and is not instance-specific. It is therefore suggested that it be implemented as a static variable at the global level in the module.

Action

  • Store the pointer to the execution information structure, if required.
  • Prepare a module information structure (if not pre-prepared), and return a pointer to this structure.

Example

This is the implementation used in the 1199 bindings.

C++ API (1199)
// module info brahms::ModuleInfo MODULE_INFO = { BRAHMS_COMPONENT_INTERFACE_REVISION, // defined in brahms-component.h COMPONENT_INTERFACE_REVISION, // defined in this module BRAHMS_BINDING_NAME, // defined by the binding MODULE_FLAGS // defined in this module }; ... // store engine attached to this instance brahms::Symbol hEngine = S_NULL; // event handler BRAHMS_DLL_EXPORT Symbol EventHandler(brahms::Event* event) { switch (event->type) { case EVENT_MODULE_INIT: { // get event data brahms::EventModuleInit* init = (brahms::EventModuleInit*) event->data; // store engine instance that called us hEngine = init->executionInfo->hEngine; // return module info structure init->moduleInfo = &MODULE_INFO; // ok break; } ... } }