Overview
C API (Component Interface)
struct EventModuleCreate { Symbol hComponent; const struct ComponentCreate* create; const struct ComponentData* data; const struct ComponentInfo* info; };

The module should instantiate a new component and return it in event->object. This object will be passed back to the module in future in the context of each further event fired on this component instantiation. Finally, the same object will be passed to a paired call to EVENT_MODULE_DESTROY when its work is done.

The module should also return ComponentInfo for the new component object.

Context

This event is fired multiple times shortly after module loading to instantiate as many copies of a component as the executed system requires.

Fields

Symbol hComponent IN
This is the symbol (handle) of the new component, and should be stored for later use in calls to the framework.
ComponentCreate* create IN
Specific information on creation. Currently, there is nothing of use here to the native component - this data is used by language bindings only.
ComponentData* data IN
Component-specific data; this pointer may be kept and dereferenced at any time later to obtain the framework-maintained data for this component. You should NOT keep the pointers that are fields of data, since these may become invalid on later calls - only keep the pointer data itself.
ComponentInfo* info IN
The module should return a pointer to a structure filled with component information. The pointer must be valid for the lifetime of the component.

Action

  • Store any of the passed information that is required in future.
  • Prepare a component information structure (if not pre-prepared).
  • Return a pointer to this structure.
  • Create a new component and store it in event->object.

Example

This is the implementation used in the 1199 bindings.

C++ API (1199)
case EVENT_MODULE_CREATE: { EventModuleCreate* emc = (EventModuleCreate*) event->data; emc->info = &COMPONENT_INFO; COMPONENT_CLASS_CPP* newObject = new COMPONENT_CLASS_CPP; event->object = newObject; newObject->initialize(emc->hComponent, emc->data); return C_OK; }