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

The module should take a copy of the passed system information structure, and return a pointer to a module-level module information structure. The most salient part of this exchange is the passing of zero or more flags to the framework indicating what constraints the module insists upon.

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. Of most use are the execution parameters, which are available within. Engine version may be of use in future, but can currently be ignored.
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 recommended that it be implemented as a static variable at the global level in the module.

Action

  • Store the pointer to the system information structure, if required.
  • Prepare a module information structure (if not pre-prepared), including setting flags.
  • Return a pointer to this structure.

Example

This is the implementation used in the 1199 bindings.

C++ API (1199)
// module-global variable (compile-time engine version) const FrameworkVersion MODULE_VERSION_ENGINE = { VERSION_ENGINE_MAJ, VERSION_ENGINE_MIN, VERSION_ENGINE_REL, VERSION_ENGINE_REV }; // module-global variable (pointer to ExecutionInfo) ExecutionInfo* executionInfo = NULL; // module-global variable ModuleInfo MODULE_MODULE_INFO = { &MODULE_VERSION_ENGINE, MODULE_OVERLAY, MODULE_FLAGS }; ... // event handler C_EXPORT Symbol EventHandler(Event* event) { switch (event->type) { case EVENT_MODULE_INIT: { EventModuleInit* init = (EventModuleInit*) event->data; executionInfo = init->executionInfo; init->moduleInfo = &MODULE_MODULE_INFO; return C_OK; } ... } }