| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989 |
- /*
- WARNING: THIS FILE IS AUTO-GENERATED. DO NOT MODIFY.
- This file was generated from Topics.idl using "rtiddsgen".
- The rtiddsgen tool is part of the RTI Connext distribution.
- For more information, type 'rtiddsgen -help' at a command shell
- or consult the RTI Connext manual.
- */
- #include <string.h>
- #ifndef ndds_cpp_h
- #include "ndds/ndds_cpp.h"
- #endif
- #ifndef osapi_type_h
- #include "osapi/osapi_type.h"
- #endif
- #ifndef osapi_heap_h
- #include "osapi/osapi_heap.h"
- #endif
- #ifndef osapi_utility_h
- #include "osapi/osapi_utility.h"
- #endif
- #ifndef cdr_type_h
- #include "cdr/cdr_type.h"
- #endif
- #ifndef cdr_type_object_h
- #include "cdr/cdr_typeObject.h"
- #endif
- #ifndef cdr_encapsulation_h
- #include "cdr/cdr_encapsulation.h"
- #endif
- #ifndef cdr_stream_h
- #include "cdr/cdr_stream.h"
- #endif
- #include "xcdr/xcdr_interpreter.h"
- #include "xcdr/xcdr_stream.h"
- #ifndef cdr_log_h
- #include "cdr/cdr_log.h"
- #endif
- #ifndef pres_typePlugin_h
- #include "pres/pres_typePlugin.h"
- #endif
- #include "dds_c/dds_c_typecode_impl.h"
- #define RTI_CDR_CURRENT_SUBMODULE RTI_CDR_SUBMODULE_MASK_STREAM
- #include <new>
- #include "TopicsPlugin.h"
- /* ----------------------------------------------------------------------------
- * Type TopicSample_SomeBytes
- * -------------------------------------------------------------------------- */
- /* -----------------------------------------------------------------------------
- Support functions:
- * -------------------------------------------------------------------------- */
- TopicSample_SomeBytes*
- TopicSample_SomeBytesPluginSupport_create_data_w_params(
- const struct DDS_TypeAllocationParams_t * alloc_params)
- {
- TopicSample_SomeBytes *sample = NULL;
- sample = new (std::nothrow) TopicSample_SomeBytes ;
- if (sample == NULL) {
- return NULL;
- }
- if (!TopicSample_SomeBytes_initialize_w_params(sample,alloc_params)) {
- delete sample;
- sample=NULL;
- }
- return sample;
- }
- TopicSample_SomeBytes *
- TopicSample_SomeBytesPluginSupport_create_data_ex(RTIBool allocate_pointers)
- {
- TopicSample_SomeBytes *sample = NULL;
- sample = new (std::nothrow) TopicSample_SomeBytes ;
- if(sample == NULL) {
- return NULL;
- }
- if (!TopicSample_SomeBytes_initialize_ex(sample,allocate_pointers, RTI_TRUE)) {
- delete sample;
- sample=NULL;
- }
- return sample;
- }
- TopicSample_SomeBytes *
- TopicSample_SomeBytesPluginSupport_create_data(void)
- {
- return TopicSample_SomeBytesPluginSupport_create_data_ex(RTI_TRUE);
- }
- void
- TopicSample_SomeBytesPluginSupport_destroy_data_w_params(
- TopicSample_SomeBytes *sample,
- const struct DDS_TypeDeallocationParams_t * dealloc_params) {
- TopicSample_SomeBytes_finalize_w_params(sample,dealloc_params);
- delete sample;
- sample=NULL;
- }
- void
- TopicSample_SomeBytesPluginSupport_destroy_data_ex(
- TopicSample_SomeBytes *sample,RTIBool deallocate_pointers) {
- TopicSample_SomeBytes_finalize_ex(sample,deallocate_pointers);
- delete sample;
- sample=NULL;
- }
- void
- TopicSample_SomeBytesPluginSupport_destroy_data(
- TopicSample_SomeBytes *sample) {
- TopicSample_SomeBytesPluginSupport_destroy_data_ex(sample,RTI_TRUE);
- }
- RTIBool
- TopicSample_SomeBytesPluginSupport_copy_data(
- TopicSample_SomeBytes *dst,
- const TopicSample_SomeBytes *src)
- {
- return TopicSample_SomeBytes_copy(dst,(const TopicSample_SomeBytes*) src);
- }
- void
- TopicSample_SomeBytesPluginSupport_print_data(
- const TopicSample_SomeBytes *sample,
- const char *desc,
- unsigned int indent_level)
- {
- RTICdrType_printIndent(indent_level);
- if (desc != NULL) {
- RTILog_debug("%s:\n", desc);
- } else {
- RTILog_debug("\n");
- }
- if (sample == NULL) {
- RTILog_debug("NULL\n");
- return;
- }
- if (DDS_OctetSeq_get_contiguous_bufferI(sample) != NULL) {
- RTICdrType_printArray(
- DDS_OctetSeq_get_contiguous_bufferI(sample),
- DDS_OctetSeq_get_length(sample),
- RTI_CDR_OCTET_SIZE,
- (RTICdrTypePrintFunction)RTICdrType_printOctet,
- "", indent_level + 1);
- } else {
- RTICdrType_printPointerArray(
- DDS_OctetSeq_get_discontiguous_bufferI(sample),
- DDS_OctetSeq_get_length(sample ),
- (RTICdrTypePrintFunction)RTICdrType_printOctet,
- "", indent_level + 1);
- }
- }
- /* ----------------------------------------------------------------------------
- Callback functions:
- * ---------------------------------------------------------------------------- */
- RTIBool
- TopicSample_SomeBytesPlugin_copy_sample(
- PRESTypePluginEndpointData endpoint_data,
- TopicSample_SomeBytes *dst,
- const TopicSample_SomeBytes *src)
- {
- if (endpoint_data) {} /* To avoid warnings */
- return TopicSample_SomeBytesPluginSupport_copy_data(dst,src);
- }
- /* ----------------------------------------------------------------------------
- (De)Serialize functions:
- * ------------------------------------------------------------------------- */
- unsigned int
- TopicSample_SomeBytesPlugin_get_serialized_sample_max_size(
- PRESTypePluginEndpointData endpoint_data,
- RTIBool include_encapsulation,
- RTIEncapsulationId encapsulation_id,
- unsigned int current_alignment);
- unsigned int
- TopicSample_SomeBytesPlugin_get_serialized_sample_max_size(
- PRESTypePluginEndpointData endpoint_data,
- RTIBool include_encapsulation,
- RTIEncapsulationId encapsulation_id,
- unsigned int current_alignment)
- {
- unsigned int size;
- RTIBool overflow = RTI_FALSE;
- size = PRESTypePlugin_interpretedGetSerializedSampleMaxSize(
- endpoint_data,&overflow,include_encapsulation,encapsulation_id,current_alignment);
- if (overflow) {
- size = RTI_CDR_MAX_SERIALIZED_SIZE;
- }
- return size;
- }
- /* --------------------------------------------------------------------------------------
- Key Management functions:
- * -------------------------------------------------------------------------------------- */
- PRESTypePluginKeyKind
- TopicSample_SomeBytesPlugin_get_key_kind(void)
- {
- return PRES_TYPEPLUGIN_NO_KEY;
- }
- unsigned int
- TopicSample_SomeBytesPlugin_get_serialized_key_max_size(
- PRESTypePluginEndpointData endpoint_data,
- RTIBool include_encapsulation,
- RTIEncapsulationId encapsulation_id,
- unsigned int current_alignment)
- {
- unsigned int size;
- RTIBool overflow = RTI_FALSE;
- size = PRESTypePlugin_interpretedGetSerializedKeyMaxSize(
- endpoint_data,&overflow,include_encapsulation,encapsulation_id,current_alignment);
- if (overflow) {
- size = RTI_CDR_MAX_SERIALIZED_SIZE;
- }
- return size;
- }
- unsigned int
- TopicSample_SomeBytesPlugin_get_serialized_key_max_size_for_keyhash(
- PRESTypePluginEndpointData endpoint_data,
- RTIEncapsulationId encapsulation_id,
- unsigned int current_alignment)
- {
- unsigned int size;
- RTIBool overflow = RTI_FALSE;
- size = PRESTypePlugin_interpretedGetSerializedKeyMaxSizeForKeyhash(
- endpoint_data,
- &overflow,
- encapsulation_id,
- current_alignment);
- if (overflow) {
- size = RTI_CDR_MAX_SERIALIZED_SIZE;
- }
- return size;
- }
- /* ------------------------------------------------------------------------
- * Plug-in Installation Methods
- * ------------------------------------------------------------------------ */
- /* ----------------------------------------------------------------------------
- * Type TopicSample_Message
- * -------------------------------------------------------------------------- */
- /* -----------------------------------------------------------------------------
- Support functions:
- * -------------------------------------------------------------------------- */
- TopicSample_Message*
- TopicSample_MessagePluginSupport_create_data_w_params(
- const struct DDS_TypeAllocationParams_t * alloc_params)
- {
- TopicSample_Message *sample = NULL;
- sample = new (std::nothrow) TopicSample_Message ;
- if (sample == NULL) {
- return NULL;
- }
- if (!TopicSample_Message_initialize_w_params(sample,alloc_params)) {
- delete sample;
- sample=NULL;
- }
- return sample;
- }
- TopicSample_Message *
- TopicSample_MessagePluginSupport_create_data_ex(RTIBool allocate_pointers)
- {
- TopicSample_Message *sample = NULL;
- sample = new (std::nothrow) TopicSample_Message ;
- if(sample == NULL) {
- return NULL;
- }
- if (!TopicSample_Message_initialize_ex(sample,allocate_pointers, RTI_TRUE)) {
- delete sample;
- sample=NULL;
- }
- return sample;
- }
- TopicSample_Message *
- TopicSample_MessagePluginSupport_create_data(void)
- {
- return TopicSample_MessagePluginSupport_create_data_ex(RTI_TRUE);
- }
- void
- TopicSample_MessagePluginSupport_destroy_data_w_params(
- TopicSample_Message *sample,
- const struct DDS_TypeDeallocationParams_t * dealloc_params) {
- TopicSample_Message_finalize_w_params(sample,dealloc_params);
- delete sample;
- sample=NULL;
- }
- void
- TopicSample_MessagePluginSupport_destroy_data_ex(
- TopicSample_Message *sample,RTIBool deallocate_pointers) {
- TopicSample_Message_finalize_ex(sample,deallocate_pointers);
- delete sample;
- sample=NULL;
- }
- void
- TopicSample_MessagePluginSupport_destroy_data(
- TopicSample_Message *sample) {
- TopicSample_MessagePluginSupport_destroy_data_ex(sample,RTI_TRUE);
- }
- RTIBool
- TopicSample_MessagePluginSupport_copy_data(
- TopicSample_Message *dst,
- const TopicSample_Message *src)
- {
- return TopicSample_Message_copy(dst,(const TopicSample_Message*) src);
- }
- void
- TopicSample_MessagePluginSupport_print_data(
- const TopicSample_Message *sample,
- const char *desc,
- unsigned int indent_level)
- {
- RTICdrType_printIndent(indent_level);
- if (desc != NULL) {
- RTILog_debug("%s:\n", desc);
- } else {
- RTILog_debug("\n");
- }
- if (sample == NULL) {
- RTILog_debug("NULL\n");
- return;
- }
- if (sample->msgname==NULL) {
- RTICdrType_printString(
- NULL,"msgname", indent_level + 1);
- } else {
- RTICdrType_printString(
- sample->msgname,"msgname", indent_level + 1);
- }
- RTICdrType_printLong(
- &sample->counter, "counter", indent_level + 1);
- RTICdrType_printLongLong(
- &sample->sendtime, "sendtime", indent_level + 1);
- TopicSample_SomeBytesPluginSupport_print_data(
- (const TopicSample_SomeBytes*) &sample->xdata, "xdata", indent_level + 1);
- }
- /* ----------------------------------------------------------------------------
- Callback functions:
- * ---------------------------------------------------------------------------- */
- PRESTypePluginParticipantData
- TopicSample_MessagePlugin_on_participant_attached(
- void *registration_data,
- const struct PRESTypePluginParticipantInfo *participant_info,
- RTIBool top_level_registration,
- void *container_plugin_context,
- RTICdrTypeCode *type_code)
- {
- struct RTIXCdrInterpreterPrograms *programs = NULL;
- struct PRESTypePluginDefaultParticipantData *pd = NULL;
- struct RTIXCdrInterpreterProgramsGenProperty programProperty =
- RTIXCdrInterpreterProgramsGenProperty_INITIALIZER;
- if (registration_data) {} /* To avoid warnings */
- if (participant_info) {} /* To avoid warnings */
- if (top_level_registration) {} /* To avoid warnings */
- if (container_plugin_context) {} /* To avoid warnings */
- if (type_code) {} /* To avoid warnings */
- pd = (struct PRESTypePluginDefaultParticipantData *)
- PRESTypePluginDefaultParticipantData_new(participant_info);
- programProperty.generateV1Encapsulation = RTI_XCDR_TRUE;
- programProperty.generateV2Encapsulation = RTI_XCDR_TRUE;
- programProperty.resolveAlias = RTI_XCDR_TRUE;
- programProperty.inlineStruct = RTI_XCDR_TRUE;
- programProperty.optimizeEnum = RTI_XCDR_TRUE;
- programs = DDS_TypeCodeFactory_assert_programs_in_global_list(
- DDS_TypeCodeFactory_get_instance(),
- TopicSample_Message_get_typecode(),
- &programProperty,
- RTI_XCDR_PROGRAM_MASK_TYPEPLUGIN);
- if (programs == NULL) {
- PRESTypePluginDefaultParticipantData_delete(
- (PRESTypePluginParticipantData) pd);
- return NULL;
- }
- pd->programs = programs;
- return (PRESTypePluginParticipantData)pd;
- }
- void
- TopicSample_MessagePlugin_on_participant_detached(
- PRESTypePluginParticipantData participant_data)
- {
- if (participant_data != NULL) {
- struct PRESTypePluginDefaultParticipantData *pd =
- (struct PRESTypePluginDefaultParticipantData *)participant_data;
- if (pd->programs != NULL) {
- DDS_TypeCodeFactory_remove_programs_from_global_list(
- DDS_TypeCodeFactory_get_instance(),
- pd->programs);
- pd->programs = NULL;
- }
- PRESTypePluginDefaultParticipantData_delete(participant_data);
- }
- }
- PRESTypePluginEndpointData
- TopicSample_MessagePlugin_on_endpoint_attached(
- PRESTypePluginParticipantData participant_data,
- const struct PRESTypePluginEndpointInfo *endpoint_info,
- RTIBool top_level_registration,
- void *containerPluginContext)
- {
- PRESTypePluginEndpointData epd = NULL;
- unsigned int serializedSampleMaxSize = 0;
- if (top_level_registration) {} /* To avoid warnings */
- if (containerPluginContext) {} /* To avoid warnings */
- if (participant_data == NULL) {
- return NULL;
- }
- epd = PRESTypePluginDefaultEndpointData_new(
- participant_data,
- endpoint_info,
- (PRESTypePluginDefaultEndpointDataCreateSampleFunction)
- TopicSample_MessagePluginSupport_create_data,
- (PRESTypePluginDefaultEndpointDataDestroySampleFunction)
- TopicSample_MessagePluginSupport_destroy_data,
- NULL , NULL );
- if (epd == NULL) {
- return NULL;
- }
- if (endpoint_info->endpointKind == PRES_TYPEPLUGIN_ENDPOINT_WRITER) {
- serializedSampleMaxSize = TopicSample_MessagePlugin_get_serialized_sample_max_size(
- epd,RTI_FALSE,RTI_CDR_ENCAPSULATION_ID_CDR_BE,0);
- PRESTypePluginDefaultEndpointData_setMaxSizeSerializedSample(epd, serializedSampleMaxSize);
- if (PRESTypePluginDefaultEndpointData_createWriterPool(
- epd,
- endpoint_info,
- (PRESTypePluginGetSerializedSampleMaxSizeFunction)
- TopicSample_MessagePlugin_get_serialized_sample_max_size, epd,
- (PRESTypePluginGetSerializedSampleSizeFunction)
- PRESTypePlugin_interpretedGetSerializedSampleSize,
- epd) == RTI_FALSE) {
- PRESTypePluginDefaultEndpointData_delete(epd);
- return NULL;
- }
- }
- return epd;
- }
- void
- TopicSample_MessagePlugin_on_endpoint_detached(
- PRESTypePluginEndpointData endpoint_data)
- {
- PRESTypePluginDefaultEndpointData_delete(endpoint_data);
- }
- void
- TopicSample_MessagePlugin_return_sample(
- PRESTypePluginEndpointData endpoint_data,
- TopicSample_Message *sample,
- void *handle)
- {
- TopicSample_Message_finalize_optional_members(sample, RTI_TRUE);
- PRESTypePluginDefaultEndpointData_returnSample(
- endpoint_data, sample, handle);
- }
- RTIBool
- TopicSample_MessagePlugin_copy_sample(
- PRESTypePluginEndpointData endpoint_data,
- TopicSample_Message *dst,
- const TopicSample_Message *src)
- {
- if (endpoint_data) {} /* To avoid warnings */
- return TopicSample_MessagePluginSupport_copy_data(dst,src);
- }
- /* ----------------------------------------------------------------------------
- (De)Serialize functions:
- * ------------------------------------------------------------------------- */
- unsigned int
- TopicSample_MessagePlugin_get_serialized_sample_max_size(
- PRESTypePluginEndpointData endpoint_data,
- RTIBool include_encapsulation,
- RTIEncapsulationId encapsulation_id,
- unsigned int current_alignment);
- RTIBool
- TopicSample_MessagePlugin_serialize_to_cdr_buffer_ex(
- char *buffer,
- unsigned int *length,
- const TopicSample_Message *sample,
- DDS_DataRepresentationId_t representation)
- {
- RTIEncapsulationId encapsulationId = RTI_CDR_ENCAPSULATION_ID_INVALID;
- struct RTICdrStream stream;
- struct PRESTypePluginDefaultEndpointData epd;
- RTIBool result;
- struct PRESTypePluginDefaultParticipantData pd;
- struct RTIXCdrTypePluginProgramContext defaultProgramConext =
- RTIXCdrTypePluginProgramContext_INTIALIZER;
- struct PRESTypePlugin plugin;
- if (length == NULL) {
- return RTI_FALSE;
- }
- RTIOsapiMemory_zero(&epd, sizeof(struct PRESTypePluginDefaultEndpointData));
- epd.programContext = defaultProgramConext;
- epd._participantData = &pd;
- epd.typePlugin = &plugin;
- epd.programContext.endpointPluginData = &epd;
- plugin.typeCode = (struct RTICdrTypeCode *)
- TopicSample_Message_get_typecode();
- pd.programs = TopicSample_MessagePlugin_get_programs();
- if (pd.programs == NULL) {
- return RTI_FALSE;
- }
- encapsulationId = DDS_TypeCode_get_native_encapsulation(
- (DDS_TypeCode *) plugin.typeCode,
- representation);
- if (encapsulationId == RTI_CDR_ENCAPSULATION_ID_INVALID) {
- return RTI_FALSE;
- }
- epd._maxSizeSerializedSample =
- TopicSample_MessagePlugin_get_serialized_sample_max_size(
- (PRESTypePluginEndpointData)&epd,
- RTI_TRUE,
- encapsulationId,
- 0);
- if (buffer == NULL) {
- *length =
- PRESTypePlugin_interpretedGetSerializedSampleSize(
- (PRESTypePluginEndpointData)&epd,
- RTI_TRUE,
- encapsulationId,
- 0,
- sample);
- if (*length == 0) {
- return RTI_FALSE;
- }
- return RTI_TRUE;
- }
- RTICdrStream_init(&stream);
- RTICdrStream_set(&stream, (char *)buffer, *length);
- result = PRESTypePlugin_interpretedSerialize(
- (PRESTypePluginEndpointData)&epd,
- sample,
- &stream,
- RTI_TRUE,
- encapsulationId,
- RTI_TRUE,
- NULL);
- *length = RTICdrStream_getCurrentPositionOffset(&stream);
- return result;
- }
- RTIBool
- TopicSample_MessagePlugin_serialize_to_cdr_buffer(
- char *buffer,
- unsigned int *length,
- const TopicSample_Message *sample)
- {
- return TopicSample_MessagePlugin_serialize_to_cdr_buffer_ex(
- buffer,
- length,
- sample,
- DDS_AUTO_DATA_REPRESENTATION);
- }
- RTIBool
- TopicSample_MessagePlugin_deserialize_from_cdr_buffer(
- TopicSample_Message *sample,
- const char * buffer,
- unsigned int length)
- {
- struct RTICdrStream stream;
- struct PRESTypePluginDefaultEndpointData epd;
- struct RTIXCdrTypePluginProgramContext defaultProgramConext =
- RTIXCdrTypePluginProgramContext_INTIALIZER;
- struct PRESTypePluginDefaultParticipantData pd;
- struct PRESTypePlugin plugin;
- epd.programContext = defaultProgramConext;
- epd._participantData = &pd;
- epd.typePlugin = &plugin;
- epd.programContext.endpointPluginData = &epd;
- plugin.typeCode = (struct RTICdrTypeCode *)
- TopicSample_Message_get_typecode();
- pd.programs = TopicSample_MessagePlugin_get_programs();
- if (pd.programs == NULL) {
- return RTI_FALSE;
- }
- epd._assignabilityProperty.acceptUnknownEnumValue = RTI_XCDR_TRUE;
- epd._assignabilityProperty.acceptUnknownUnionDiscriminator = RTI_XCDR_TRUE;
- RTICdrStream_init(&stream);
- RTICdrStream_set(&stream, (char *)buffer, length);
- TopicSample_Message_finalize_optional_members(sample, RTI_TRUE);
- return PRESTypePlugin_interpretedDeserialize(
- (PRESTypePluginEndpointData)&epd, sample,
- &stream, RTI_TRUE, RTI_TRUE,
- NULL);
- }
- #ifndef NDDS_STANDALONE_TYPE
- DDS_ReturnCode_t
- TopicSample_MessagePlugin_data_to_string(
- const TopicSample_Message *sample,
- char *str,
- DDS_UnsignedLong *str_size,
- const struct DDS_PrintFormatProperty *property)
- {
- DDS_DynamicData *data = NULL;
- char *buffer = NULL;
- unsigned int length = 0;
- struct DDS_PrintFormat printFormat;
- DDS_ReturnCode_t retCode = DDS_RETCODE_ERROR;
- if (sample == NULL) {
- return DDS_RETCODE_BAD_PARAMETER;
- }
- if (str_size == NULL) {
- return DDS_RETCODE_BAD_PARAMETER;
- }
- if (property == NULL) {
- return DDS_RETCODE_BAD_PARAMETER;
- }
- if (!TopicSample_MessagePlugin_serialize_to_cdr_buffer(
- NULL,
- &length,
- sample)) {
- return DDS_RETCODE_ERROR;
- }
- RTIOsapiHeap_allocateBuffer(&buffer, length, RTI_OSAPI_ALIGNMENT_DEFAULT);
- if (buffer == NULL) {
- return DDS_RETCODE_ERROR;
- }
- if (!TopicSample_MessagePlugin_serialize_to_cdr_buffer(
- buffer,
- &length,
- sample)) {
- RTIOsapiHeap_freeBuffer(buffer);
- return DDS_RETCODE_ERROR;
- }
- data = DDS_DynamicData_new(
- TopicSample_Message_get_typecode(),
- &DDS_DYNAMIC_DATA_PROPERTY_DEFAULT);
- if (data == NULL) {
- RTIOsapiHeap_freeBuffer(buffer);
- return DDS_RETCODE_ERROR;
- }
- retCode = DDS_DynamicData_from_cdr_buffer(data, buffer, length);
- if (retCode != DDS_RETCODE_OK) {
- RTIOsapiHeap_freeBuffer(buffer);
- DDS_DynamicData_delete(data);
- return retCode;
- }
- retCode = DDS_PrintFormatProperty_to_print_format(
- property,
- &printFormat);
- if (retCode != DDS_RETCODE_OK) {
- RTIOsapiHeap_freeBuffer(buffer);
- DDS_DynamicData_delete(data);
- return retCode;
- }
- retCode = DDS_DynamicDataFormatter_to_string_w_format(
- data,
- str,
- str_size,
- &printFormat);
- if (retCode != DDS_RETCODE_OK) {
- RTIOsapiHeap_freeBuffer(buffer);
- DDS_DynamicData_delete(data);
- return retCode;
- }
- RTIOsapiHeap_freeBuffer(buffer);
- DDS_DynamicData_delete(data);
- return DDS_RETCODE_OK;
- }
- #endif
- unsigned int
- TopicSample_MessagePlugin_get_serialized_sample_max_size(
- PRESTypePluginEndpointData endpoint_data,
- RTIBool include_encapsulation,
- RTIEncapsulationId encapsulation_id,
- unsigned int current_alignment)
- {
- unsigned int size;
- RTIBool overflow = RTI_FALSE;
- size = PRESTypePlugin_interpretedGetSerializedSampleMaxSize(
- endpoint_data,&overflow,include_encapsulation,encapsulation_id,current_alignment);
- if (overflow) {
- size = RTI_CDR_MAX_SERIALIZED_SIZE;
- }
- return size;
- }
- /* --------------------------------------------------------------------------------------
- Key Management functions:
- * -------------------------------------------------------------------------------------- */
- PRESTypePluginKeyKind
- TopicSample_MessagePlugin_get_key_kind(void)
- {
- return PRES_TYPEPLUGIN_NO_KEY;
- }
- RTIBool TopicSample_MessagePlugin_deserialize_key(
- PRESTypePluginEndpointData endpoint_data,
- TopicSample_Message **sample,
- RTIBool * drop_sample,
- struct RTICdrStream *stream,
- RTIBool deserialize_encapsulation,
- RTIBool deserialize_key,
- void *endpoint_plugin_qos)
- {
- RTIBool result;
- if (drop_sample) {} /* To avoid warnings */
- stream->_xTypesState.unassignable = RTI_FALSE;
- result= PRESTypePlugin_interpretedDeserializeKey(
- endpoint_data, (sample != NULL)?*sample:NULL, stream,
- deserialize_encapsulation, deserialize_key, endpoint_plugin_qos);
- if (result) {
- if (stream->_xTypesState.unassignable) {
- result = RTI_FALSE;
- }
- }
- return result;
- }
- unsigned int
- TopicSample_MessagePlugin_get_serialized_key_max_size(
- PRESTypePluginEndpointData endpoint_data,
- RTIBool include_encapsulation,
- RTIEncapsulationId encapsulation_id,
- unsigned int current_alignment)
- {
- unsigned int size;
- RTIBool overflow = RTI_FALSE;
- size = PRESTypePlugin_interpretedGetSerializedKeyMaxSize(
- endpoint_data,&overflow,include_encapsulation,encapsulation_id,current_alignment);
- if (overflow) {
- size = RTI_CDR_MAX_SERIALIZED_SIZE;
- }
- return size;
- }
- unsigned int
- TopicSample_MessagePlugin_get_serialized_key_max_size_for_keyhash(
- PRESTypePluginEndpointData endpoint_data,
- RTIEncapsulationId encapsulation_id,
- unsigned int current_alignment)
- {
- unsigned int size;
- RTIBool overflow = RTI_FALSE;
- size = PRESTypePlugin_interpretedGetSerializedKeyMaxSizeForKeyhash(
- endpoint_data,
- &overflow,
- encapsulation_id,
- current_alignment);
- if (overflow) {
- size = RTI_CDR_MAX_SERIALIZED_SIZE;
- }
- return size;
- }
- struct RTIXCdrInterpreterPrograms *TopicSample_MessagePlugin_get_programs()
- {
- return ::rti::xcdr::get_cdr_serialization_programs<
- TopicSample_Message,
- true, true, true>();
- }
- /* ------------------------------------------------------------------------
- * Plug-in Installation Methods
- * ------------------------------------------------------------------------ */
- struct PRESTypePlugin *TopicSample_MessagePlugin_new(void)
- {
- struct PRESTypePlugin *plugin = NULL;
- const struct PRESTypePluginVersion PLUGIN_VERSION =
- PRES_TYPE_PLUGIN_VERSION_2_0;
- RTIOsapiHeap_allocateStructure(
- &plugin, struct PRESTypePlugin);
- if (plugin == NULL) {
- return NULL;
- }
- plugin->version = PLUGIN_VERSION;
- /* set up parent's function pointers */
- plugin->onParticipantAttached =
- (PRESTypePluginOnParticipantAttachedCallback)
- TopicSample_MessagePlugin_on_participant_attached;
- plugin->onParticipantDetached =
- (PRESTypePluginOnParticipantDetachedCallback)
- TopicSample_MessagePlugin_on_participant_detached;
- plugin->onEndpointAttached =
- (PRESTypePluginOnEndpointAttachedCallback)
- TopicSample_MessagePlugin_on_endpoint_attached;
- plugin->onEndpointDetached =
- (PRESTypePluginOnEndpointDetachedCallback)
- TopicSample_MessagePlugin_on_endpoint_detached;
- plugin->copySampleFnc =
- (PRESTypePluginCopySampleFunction)
- TopicSample_MessagePlugin_copy_sample;
- plugin->createSampleFnc =
- (PRESTypePluginCreateSampleFunction)
- TopicSample_MessagePlugin_create_sample;
- plugin->destroySampleFnc =
- (PRESTypePluginDestroySampleFunction)
- TopicSample_MessagePlugin_destroy_sample;
- plugin->finalizeOptionalMembersFnc =
- (PRESTypePluginFinalizeOptionalMembersFunction)
- TopicSample_Message_finalize_optional_members;
- plugin->serializeFnc =
- (PRESTypePluginSerializeFunction) PRESTypePlugin_interpretedSerialize;
- plugin->deserializeFnc =
- (PRESTypePluginDeserializeFunction) PRESTypePlugin_interpretedDeserializeWithAlloc;
- plugin->getSerializedSampleMaxSizeFnc =
- (PRESTypePluginGetSerializedSampleMaxSizeFunction)
- TopicSample_MessagePlugin_get_serialized_sample_max_size;
- plugin->getSerializedSampleMinSizeFnc =
- (PRESTypePluginGetSerializedSampleMinSizeFunction)
- PRESTypePlugin_interpretedGetSerializedSampleMinSize;
- plugin->getDeserializedSampleMaxSizeFnc = NULL;
- plugin->getSampleFnc =
- (PRESTypePluginGetSampleFunction)
- TopicSample_MessagePlugin_get_sample;
- plugin->returnSampleFnc =
- (PRESTypePluginReturnSampleFunction)
- TopicSample_MessagePlugin_return_sample;
- plugin->getKeyKindFnc =
- (PRESTypePluginGetKeyKindFunction)
- TopicSample_MessagePlugin_get_key_kind;
- /* These functions are only used for keyed types. As this is not a keyed
- type they are all set to NULL
- */
- plugin->serializeKeyFnc = NULL ;
- plugin->deserializeKeyFnc = NULL;
- plugin->getKeyFnc = NULL;
- plugin->returnKeyFnc = NULL;
- plugin->instanceToKeyFnc = NULL;
- plugin->keyToInstanceFnc = NULL;
- plugin->getSerializedKeyMaxSizeFnc = NULL;
- plugin->instanceToKeyHashFnc = NULL;
- plugin->serializedSampleToKeyHashFnc = NULL;
- plugin->serializedKeyToKeyHashFnc = NULL;
- #ifdef NDDS_STANDALONE_TYPE
- plugin->typeCode = NULL;
- #else
- plugin->typeCode = (struct RTICdrTypeCode *)TopicSample_Message_get_typecode();
- #endif
- plugin->languageKind = PRES_TYPEPLUGIN_CPP_LANG;
- /* Serialized buffer */
- plugin->getBuffer =
- (PRESTypePluginGetBufferFunction)
- TopicSample_MessagePlugin_get_buffer;
- plugin->returnBuffer =
- (PRESTypePluginReturnBufferFunction)
- TopicSample_MessagePlugin_return_buffer;
- plugin->getBufferWithParams = NULL;
- plugin->returnBufferWithParams = NULL;
- plugin->getSerializedSampleSizeFnc =
- (PRESTypePluginGetSerializedSampleSizeFunction)
- PRESTypePlugin_interpretedGetSerializedSampleSize;
- plugin->getWriterLoanedSampleFnc = NULL;
- plugin->returnWriterLoanedSampleFnc = NULL;
- plugin->returnWriterLoanedSampleFromCookieFnc = NULL;
- plugin->validateWriterLoanedSampleFnc = NULL;
- plugin->setWriterLoanedSampleSerializedStateFnc = NULL;
- plugin->endpointTypeName = TopicSample_MessageTYPENAME;
- plugin->isMetpType = RTI_FALSE;
- return plugin;
- }
- void
- TopicSample_MessagePlugin_delete(struct PRESTypePlugin *plugin)
- {
- RTIOsapiHeap_freeStructure(plugin);
- }
- #undef RTI_CDR_CURRENT_SUBMODULE
|