Communication with other layers
A decoding codec plug-in's role is to decode messages from a transport layer plug-in into a normalized format that can be processed by the Semantic Mapper. To achieve this, it needs to be able to communicate with the Semantic Mapper. The accessible Semantic Mapper functionality is presented in SemanticMapper.h.
When a decoding codec starts, it is passed a handle to an AP_SemanticMapper object through its setSemanticMapper function. This object is defined in SemanticMapper.h, where functions, (of type AP_SemanticMapper_Functions*) points to the definitions for two functions:
sendNormalisedEvent getLastError Code inside a decoding codec that calls these functions on the Semantic Mapper looks as follows. Assuming that mapper holds a reference to the AP_SemanticMapper object:
errorCode = mapper->functions->sendNormalisedEvent(mapper, NormalisedEvent);
and likewise for getLastError.
AP_SemanticMapperError defines the error codes that can be returned by sendNormalisedEvent .
On the other hand, an encoding codec plug-in's role is to encode messages in normalized format into some specific format that can then be accepted by a transport layer plug-in for transmission to an external message sink (like a message bus). To achieve this, it needs to be able to communicate with a transport layer plug-in loaded in the IAF.
When an encoding codec starts, its
addEventTransport function will be called once for each available transport. For each, it is passed a handle to an
AP_EventTransport object. This object is defined in
EventTransport.h and was described in detail in
C/C++ Transport Plug-in Development. It contains a pointer to
AP_EventTransport_Functions, which in turn references the functions available in the transport layer plug-in. Of these, only two are relevant to the author of an encoding codec:
sendTransportEvent getLastError Code inside an encoding codec that calls these functions on the transport layer plug-in looks as follows. Assuming that transport holds a reference to the AP_EventTransport object:
errorCode = transport->functions->sendTransportEvent(transport, event);
and likewise for getLastError.