Overview
C API (Component Interface)
The process should marshal its content into a binary stream, and return a pointer to that stream. This call is used to propagate data between processes in non-shared-memory environments, so, for efficiency, data objects should maintain their content ready-marshaled to respond to this event, if that does not introduce overhead internally.
The stream returned must have empty space reserved at the head for the framework to insert a message header before dispatch. This should be of size contentHeaderBytes bytes, where contentHeaderBytes is passed to the Data object in EVENT_INIT_COMPLETE. This header will not be passed back to the object on a call to EVENT_CONTENT_SET (it will have been stripped off by the framework). This header should not be counted in the byte count returned in bytes .
Fields
UINT8 * stream OUT- Where the object should place a pointer to its marshaled content (including space reserved for a header).
UINT64 bytes OUT- Where the object should place the length in bytes of its marshaled content (minus the header).
Action
- If not already done, marshal content into a single binary stream. The stream need only be readable by this release of this component, since it will be used only in a call to EVENT_CONTENT_SET. The stream must have
contentHeaderBytes bytes reserved at the front for use by the framework, which should be zeroed initially.
- Return marshaled content as a binary stream, setting the two output fields specified above.
Example
C++ Source Code (against 1199)
VBYTE content ;
...
case EVENT_INIT_COMPLETE:
{
...
content .resize (contentHeaderBytes + myContentBytes );
memset (&content [0 ], 0 , contentHeaderBytes );
}
case EVENT_CONTENT_SET
{
...
for (UINT32 b =0 ; b <myContentBytes ; b ++)
{
UINT32 c = b + contentHeaderBytes ;
content [c ] = newContent [b ];
}
}
case EVENT_CONTENT_GET:
{
EventContent* ec = (EventContent*)event ->data ;
ec ->stream = &content [0 ];
ec ->bytes = myContentBytes ;
}
|