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 by copying that in event->object and return it, also in event->object. The new object will be treated similarly to an object created through EVENT_MODULE_CREATE. Finally, the new 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. Currently, this event is only fired on Data objects.

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. time is not initialised at this stage, but the pointer may be kept and dereferenced later to obtain the framework-maintained time data for this component. name is initialised on this call, but can be dereferenced at any point subsequently.
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 as a copy of event->object 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* object = (COMPONENT_CLASS_CPP*) event->object; if (!object) return E_NO_INSTANCE; COMPONENT_CLASS_CPP* newObject = new COMPONENT_CLASS_CPP(*object); event->object = newObject; newObject->initialize(emc->hComponent, emc->data); result = C_OK; break; }