Overview
C API (Component Interface)
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)
brahms ::ModuleInfo MODULE_INFO =
{
BRAHMS_COMPONENT_INTERFACE_REVISION ,
COMPONENT_INTERFACE_REVISION ,
BRAHMS_BINDING_NAME ,
MODULE_FLAGS
};
...
brahms ::Symbol hEngine = S_NULL ;
BRAHMS_DLL_EXPORT Symbol EventHandler (brahms ::Event * event )
{
switch (event ->type )
{
case EVENT_MODULE_INIT:
{
brahms ::EventModuleInit* init = (brahms ::EventModuleInit*) event ->data ;
hEngine = init ->executionInfo ->hEngine ;
init ->moduleInfo = &MODULE_INFO ;
break ;
}
...
}
}
|