Developing Apama Applications > Developing Adapters > C/C++ Codec Plug-in Development > The C/C++ codec Plug-in Development Specification > Codec functions to implement > Codec encoder functions
Codec encoder functions
If the codec is to implement an encoder, implementations need to be provided for the following functions:
sendNormalisedEvent
/**
  * Called by the Semantic Mapper to encode an event and send it on to the
  * event transport. Ownership of the message is transferred to the
  * encoder when this function is called.
  *
  * @param encoder The event encoder instance
  * @param event The event to be encoded
  * @param timeStamp Timestamps associated with this event
  * @return Event codec error code. If this is not AP_EventCodec_OK, the
  * getLastError() function of the encoder should be called to get a more
  * detailed description of what went wrong.
  */
AP_EventCodecError (*sendNormalisedEvent)(struct AP_EventEncoder* encoder,
    AP_NormalisedEvent* event, AP_TimestampSet* timeStamp);
 
flushUpstream
 
/**
  * Flush any pending normalised events into the attached event transport.
  * If event processing in the encoder is synchronous (as it usually will
  * be) this function need not do anything except return AP_EventCodec_OK.
  *
  * @param encoder The event encoder instance
  * @return Event codec error code. If this is not AP_EventCodec_OK, the
  * getLastError() function of the encoder should be called to get a more
  * detailed description of what went wrong.
  */
AP_EventCodecError (*flushUpstream)(struct AP_EventEncoder* encoder);
 
getLastError
 
/**
  * Return the encoder's stored error message, if any. The message string
  * is owned by the encoder so should not be modified or freed by the
  * caller.
  *
  * @param encoder The event encoder instance
  * @return The last error message generated by the encoder
  */
const AP_char8* (*getLastError)(struct AP_EventEncoder* encoder);
 
addEventTransport
 
/**
  * Add a named event transport to the set of transports known to the
  * encoder.
  *
  * If the named transport already exists, it should be replaced.
  *
  * @param encoder The event encoder instance
  * @param name The name of the transport to be added.
  * @param transport The transport object itself
  */
void (*addEventTransport)(struct AP_EventEncoder* encoder,
    const AP_char8* name, struct AP_EventTransport* transport);
 
removeEventTransport
 
/**
  * Remove a named event transport from the set of transports known to the
  * encoder.
  *
  * If the named transport does not exist, the function should do nothing.
  *
  * @param encoder The event encoder instance
  * @param name The name of the transport to be removed
  */
void (*removeEventTransport)(struct AP_EventEncoder* encoder,
    const AP_char8* name);
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.