From c260f85e4881a61fd985d9d848b7b684e5bceae1 Mon Sep 17 00:00:00 2001 From: Karsten Knese Date: Mon, 5 Mar 2018 15:45:09 -0800 Subject: [PATCH] [style] changes to the generated raw data idl for making CI linters happy [style] changes to generated code again --- rmw_connext_cpp/CMakeLists.txt | 22 +- .../connext_static_raw_data.hpp | 66 +- .../connext_static_raw_data_plugin.hpp | 610 ++--- .../connext_static_raw_data_support.hpp | 104 +- .../src/connext_static_raw_data.cpp | 382 ++-- .../src/connext_static_raw_data_plugin.cpp | 1956 ++++++++--------- .../src/connext_static_raw_data_support.cpp | 5 +- 7 files changed, 1576 insertions(+), 1569 deletions(-) diff --git a/rmw_connext_cpp/CMakeLists.txt b/rmw_connext_cpp/CMakeLists.txt index b1971bb6..4085a81f 100644 --- a/rmw_connext_cpp/CMakeLists.txt +++ b/rmw_connext_cpp/CMakeLists.txt @@ -128,8 +128,26 @@ if(WIN32) endif() if(BUILD_TESTING) - find_package(ament_lint_auto REQUIRED) - ament_lint_auto_find_test_dependencies() + find_package(ament_cmake_cppcheck REQUIRED) + find_package(ament_cmake_cpplint REQUIRED) + find_package(ament_cmake_lint_cmake REQUIRED) + find_package(ament_cmake_uncrustify REQUIRED) + find_package(ament_cmake_copyright REQUIRED) + ament_cppcheck() + ament_cpplint("FILTERS" "-legal/copyright") + ament_lint_cmake() + ament_uncrustify() + ament_copyright( + "--exclude" + "connext_static_raw_data.hpp" + "connext_static_raw_data_plugin.hpp" + "connext_static_raw_data_support.hpp" + "connext_static_raw_data.cpp" + "connext_static_raw_data_plugin.cpp" + "connext_static_raw_data_support.cpp" + ) + + # ament_lint_auto_find_test_dependencies() endif() ament_package(CONFIG_EXTRAS "${PROJECT_NAME}-extras.cmake") diff --git a/rmw_connext_cpp/include/rmw_connext_cpp/connext_static_raw_data.hpp b/rmw_connext_cpp/include/rmw_connext_cpp/connext_static_raw_data.hpp index 0c9d355d..4213287a 100644 --- a/rmw_connext_cpp/include/rmw_connext_cpp/connext_static_raw_data.hpp +++ b/rmw_connext_cpp/include/rmw_connext_cpp/connext_static_raw_data.hpp @@ -7,22 +7,15 @@ For more information, type 'rtiddsgen -help' at a command shell or consult the RTI Connext manual. */ -#ifndef ConnextStaticRawData_1689213465_h -#define ConnextStaticRawData_1689213465_h +#ifndef RMW_CONNEXT_CPP__CONNEXT_STATIC_RAW_DATA_HPP_ +#define RMW_CONNEXT_CPP__CONNEXT_STATIC_RAW_DATA_HPP_ -#ifndef NDDS_STANDALONE_TYPE -#ifndef ndds_cpp_h #include "rmw_connext_shared_cpp/ndds_include.hpp" -#endif -#else -#include "ndds_standalone_type.h" -#endif -static const DDS_Long KEY_HASH_LENGTH_16= 16; -extern "C" { - - extern const char *ConnextStaticRawDataTYPENAME; +static const DDS_Long KEY_HASH_LENGTH_16 = 16; +extern "C" { +extern const char * ConnextStaticRawDataTYPENAME; } struct ConnextStaticRawDataSeq; @@ -34,18 +27,17 @@ class ConnextStaticRawDataDataReader; class ConnextStaticRawData { - public: - typedef struct ConnextStaticRawDataSeq Seq; - #ifndef NDDS_STANDALONE_TYPE - typedef ConnextStaticRawDataTypeSupport TypeSupport; - typedef ConnextStaticRawDataDataWriter DataWriter; - typedef ConnextStaticRawDataDataReader DataReader; - #endif - - DDS_Octet key_hash [(KEY_HASH_LENGTH_16)]; - DDS_OctetSeq serialized_key ; - DDS_OctetSeq serialized_data ; - +public: + typedef struct ConnextStaticRawDataSeq Seq; + #ifndef NDDS_STANDALONE_TYPE + typedef ConnextStaticRawDataTypeSupport TypeSupport; + typedef ConnextStaticRawDataDataWriter DataWriter; + typedef ConnextStaticRawDataDataReader DataReader; + #endif + + DDS_Octet key_hash[(KEY_HASH_LENGTH_16)]; + DDS_OctetSeq serialized_key; + DDS_OctetSeq serialized_data; }; #if (defined(RTI_WIN32) || defined (RTI_WINCE)) && defined(NDDS_USER_DLL_EXPORT) /* If the code is building on Windows, start exporting symbols. @@ -54,44 +46,44 @@ class ConnextStaticRawData #define NDDSUSERDllExport __declspec(dllexport) #endif -NDDSUSERDllExport DDS_TypeCode* ConnextStaticRawData_get_typecode(void); /* Type code */ +NDDSUSERDllExport DDS_TypeCode * ConnextStaticRawData_get_typecode(void); DDS_SEQUENCE(ConnextStaticRawDataSeq, ConnextStaticRawData); NDDSUSERDllExport RTIBool ConnextStaticRawData_initialize( - ConnextStaticRawData* self); + ConnextStaticRawData * self); NDDSUSERDllExport RTIBool ConnextStaticRawData_initialize_ex( - ConnextStaticRawData* self,RTIBool allocatePointers,RTIBool allocateMemory); + ConnextStaticRawData * self, RTIBool allocatePointers, RTIBool allocateMemory); NDDSUSERDllExport RTIBool ConnextStaticRawData_initialize_w_params( - ConnextStaticRawData* self, - const struct DDS_TypeAllocationParams_t * allocParams); + ConnextStaticRawData * self, + const struct DDS_TypeAllocationParams_t * allocParams); NDDSUSERDllExport void ConnextStaticRawData_finalize( - ConnextStaticRawData* self); + ConnextStaticRawData * self); NDDSUSERDllExport void ConnextStaticRawData_finalize_ex( - ConnextStaticRawData* self,RTIBool deletePointers); + ConnextStaticRawData * self, RTIBool deletePointers); NDDSUSERDllExport void ConnextStaticRawData_finalize_w_params( - ConnextStaticRawData* self, - const struct DDS_TypeDeallocationParams_t * deallocParams); + ConnextStaticRawData * self, + const struct DDS_TypeDeallocationParams_t * deallocParams); NDDSUSERDllExport void ConnextStaticRawData_finalize_optional_members( - ConnextStaticRawData* self, RTIBool deletePointers); + ConnextStaticRawData * self, RTIBool deletePointers); NDDSUSERDllExport RTIBool ConnextStaticRawData_copy( - ConnextStaticRawData* dst, - const ConnextStaticRawData* src); + ConnextStaticRawData * dst, + const ConnextStaticRawData * src); #if (defined(RTI_WIN32) || defined (RTI_WINCE)) && defined(NDDS_USER_DLL_EXPORT) /* If the code is building on Windows, stop exporting symbols. @@ -100,4 +92,4 @@ RTIBool ConnextStaticRawData_copy( #define NDDSUSERDllExport #endif -#endif /* ConnextStaticRawData */ +#endif // RMW_CONNEXT_CPP__CONNEXT_STATIC_RAW_DATA_HPP_ diff --git a/rmw_connext_cpp/include/rmw_connext_cpp/connext_static_raw_data_plugin.hpp b/rmw_connext_cpp/include/rmw_connext_cpp/connext_static_raw_data_plugin.hpp index 00321bc4..e75eb98c 100644 --- a/rmw_connext_cpp/include/rmw_connext_cpp/connext_static_raw_data_plugin.hpp +++ b/rmw_connext_cpp/include/rmw_connext_cpp/connext_static_raw_data_plugin.hpp @@ -7,8 +7,8 @@ For more information, type 'rtiddsgen -help' at a command shell or consult the RTI Connext manual. */ -#ifndef ConnextStaticRawDataPlugin_1689213465_h -#define ConnextStaticRawDataPlugin_1689213465_h +#ifndef RMW_CONNEXT_CPP__CONNEXT_STATIC_RAW_DATA_PLUGIN_HPP_ +#define RMW_CONNEXT_CPP__CONNEXT_STATIC_RAW_DATA_PLUGIN_HPP_ #include "rmw_connext_cpp/connext_static_raw_data.hpp" @@ -27,308 +27,308 @@ struct RTICdrStream; extern "C" { - /* The type used to store keys for instances of type struct - * AnotherSimple. - * - * By default, this type is struct ConnextStaticRawData - * itself. However, if for some reason this choice is not practical for your - * system (e.g. if sizeof(struct ConnextStaticRawData) - * is very large), you may redefine this typedef in terms of another type of - * your choosing. HOWEVER, if you define the KeyHolder type to be something - * other than struct AnotherSimple, the - * following restriction applies: the key of struct - * ConnextStaticRawData must consist of a - * single field of your redefined KeyHolder type and that field must be the - * first field in struct ConnextStaticRawData. - */ - typedef class ConnextStaticRawData ConnextStaticRawDataKeyHolder; - - #define ConnextStaticRawDataPlugin_get_sample PRESTypePluginDefaultEndpointData_getSample - #define ConnextStaticRawDataPlugin_get_buffer PRESTypePluginDefaultEndpointData_getBuffer - #define ConnextStaticRawDataPlugin_return_buffer PRESTypePluginDefaultEndpointData_returnBuffer - - #define ConnextStaticRawDataPlugin_get_key PRESTypePluginDefaultEndpointData_getKey - #define ConnextStaticRawDataPlugin_return_key PRESTypePluginDefaultEndpointData_returnKey - - #define ConnextStaticRawDataPlugin_create_sample PRESTypePluginDefaultEndpointData_createSample - #define ConnextStaticRawDataPlugin_destroy_sample PRESTypePluginDefaultEndpointData_deleteSample - - /* -------------------------------------------------------------------------------------- - Support functions: - * -------------------------------------------------------------------------------------- */ - - NDDSUSERDllExport extern ConnextStaticRawData* - ConnextStaticRawDataPluginSupport_create_data_w_params( - const struct DDS_TypeAllocationParams_t * alloc_params); - - NDDSUSERDllExport extern ConnextStaticRawData* - ConnextStaticRawDataPluginSupport_create_data_ex(RTIBool allocate_pointers); - - NDDSUSERDllExport extern ConnextStaticRawData* - ConnextStaticRawDataPluginSupport_create_data(void); - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPluginSupport_copy_data( - ConnextStaticRawData *out, - const ConnextStaticRawData *in); - - NDDSUSERDllExport extern void - ConnextStaticRawDataPluginSupport_destroy_data_w_params( - ConnextStaticRawData *sample, - const struct DDS_TypeDeallocationParams_t * dealloc_params); - - NDDSUSERDllExport extern void - ConnextStaticRawDataPluginSupport_destroy_data_ex( - ConnextStaticRawData *sample,RTIBool deallocate_pointers); - - NDDSUSERDllExport extern void - ConnextStaticRawDataPluginSupport_destroy_data( - ConnextStaticRawData *sample); - - NDDSUSERDllExport extern void - ConnextStaticRawDataPluginSupport_print_data( - const ConnextStaticRawData *sample, - const char *desc, - unsigned int indent); - - NDDSUSERDllExport extern ConnextStaticRawData* - ConnextStaticRawDataPluginSupport_create_key_ex(RTIBool allocate_pointers); - - NDDSUSERDllExport extern ConnextStaticRawData* - ConnextStaticRawDataPluginSupport_create_key(void); - - NDDSUSERDllExport extern void - ConnextStaticRawDataPluginSupport_destroy_key_ex( - ConnextStaticRawDataKeyHolder *key,RTIBool deallocate_pointers); - - NDDSUSERDllExport extern void - ConnextStaticRawDataPluginSupport_destroy_key( - ConnextStaticRawDataKeyHolder *key); - - /* ---------------------------------------------------------------------------- - Callback functions: - * ---------------------------------------------------------------------------- */ - - NDDSUSERDllExport extern PRESTypePluginParticipantData - ConnextStaticRawDataPlugin_on_participant_attached( - void *registration_data, - const struct PRESTypePluginParticipantInfo *participant_info, - RTIBool top_level_registration, - void *container_plugin_context, - RTICdrTypeCode *typeCode); - - NDDSUSERDllExport extern void - ConnextStaticRawDataPlugin_on_participant_detached( - PRESTypePluginParticipantData participant_data); - - NDDSUSERDllExport extern PRESTypePluginEndpointData - ConnextStaticRawDataPlugin_on_endpoint_attached( - PRESTypePluginParticipantData participant_data, - const struct PRESTypePluginEndpointInfo *endpoint_info, - RTIBool top_level_registration, - void *container_plugin_context); - - NDDSUSERDllExport extern void - ConnextStaticRawDataPlugin_on_endpoint_detached( - PRESTypePluginEndpointData endpoint_data); - - NDDSUSERDllExport extern void - ConnextStaticRawDataPlugin_return_sample( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData *sample, - void *handle); - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPlugin_copy_sample( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData *out, - const ConnextStaticRawData *in); - - /* ---------------------------------------------------------------------------- - (De)Serialize functions: - * ------------------------------------------------------------------------- */ - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPlugin_serialize( - PRESTypePluginEndpointData endpoint_data, - const ConnextStaticRawData *sample, - struct RTICdrStream *stream, - RTIBool serialize_encapsulation, - RTIEncapsulationId encapsulation_id, - RTIBool serialize_sample, - void *endpoint_plugin_qos); - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPlugin_deserialize_sample( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData *sample, - struct RTICdrStream *stream, - RTIBool deserialize_encapsulation, - RTIBool deserialize_sample, - void *endpoint_plugin_qos); - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPlugin_serialize_to_cdr_buffer( - char * buffer, - unsigned int * length, - const ConnextStaticRawData *sample); - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPlugin_deserialize( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData **sample, - RTIBool * drop_sample, - struct RTICdrStream *stream, - RTIBool deserialize_encapsulation, - RTIBool deserialize_sample, - void *endpoint_plugin_qos); - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPlugin_deserialize_from_cdr_buffer( - ConnextStaticRawData *sample, - const char * buffer, - unsigned int length); - NDDSUSERDllExport extern DDS_ReturnCode_t - ConnextStaticRawDataPlugin_data_to_string( - const ConnextStaticRawData *sample, - char *str, - DDS_UnsignedLong *str_size, - const struct DDS_PrintFormatProperty *property); - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPlugin_skip( - PRESTypePluginEndpointData endpoint_data, - struct RTICdrStream *stream, - RTIBool skip_encapsulation, - RTIBool skip_sample, - void *endpoint_plugin_qos); - - NDDSUSERDllExport extern unsigned int - ConnextStaticRawDataPlugin_get_serialized_sample_max_size_ex( - PRESTypePluginEndpointData endpoint_data, - RTIBool * overflow, - RTIBool include_encapsulation, - RTIEncapsulationId encapsulation_id, - unsigned int current_alignment); - - NDDSUSERDllExport extern unsigned int - ConnextStaticRawDataPlugin_get_serialized_sample_max_size( - PRESTypePluginEndpointData endpoint_data, - RTIBool include_encapsulation, - RTIEncapsulationId encapsulation_id, - unsigned int current_alignment); - - NDDSUSERDllExport extern unsigned int - ConnextStaticRawDataPlugin_get_serialized_sample_min_size( - PRESTypePluginEndpointData endpoint_data, - RTIBool include_encapsulation, - RTIEncapsulationId encapsulation_id, - unsigned int current_alignment); - - NDDSUSERDllExport extern unsigned int - ConnextStaticRawDataPlugin_get_serialized_sample_size( - PRESTypePluginEndpointData endpoint_data, - RTIBool include_encapsulation, - RTIEncapsulationId encapsulation_id, - unsigned int current_alignment, - const ConnextStaticRawData * sample); - - /* -------------------------------------------------------------------------------------- - Key Management functions: - * -------------------------------------------------------------------------------------- */ - NDDSUSERDllExport extern PRESTypePluginKeyKind - ConnextStaticRawDataPlugin_get_key_kind(void); - - NDDSUSERDllExport extern unsigned int - ConnextStaticRawDataPlugin_get_serialized_key_max_size_ex( - PRESTypePluginEndpointData endpoint_data, - RTIBool * overflow, - RTIBool include_encapsulation, - RTIEncapsulationId encapsulation_id, - unsigned int current_alignment); - - NDDSUSERDllExport extern unsigned int - ConnextStaticRawDataPlugin_get_serialized_key_max_size( - PRESTypePluginEndpointData endpoint_data, - RTIBool include_encapsulation, - RTIEncapsulationId encapsulation_id, - unsigned int current_alignment); - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPlugin_serialize_key( - PRESTypePluginEndpointData endpoint_data, - const ConnextStaticRawData *sample, - struct RTICdrStream *stream, - RTIBool serialize_encapsulation, - RTIEncapsulationId encapsulation_id, - RTIBool serialize_key, - void *endpoint_plugin_qos); - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPlugin_deserialize_key_sample( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData * sample, - struct RTICdrStream *stream, - RTIBool deserialize_encapsulation, - RTIBool deserialize_key, - void *endpoint_plugin_qos); - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPlugin_deserialize_key( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData ** sample, - RTIBool * drop_sample, - struct RTICdrStream *stream, - RTIBool deserialize_encapsulation, - RTIBool deserialize_key, - void *endpoint_plugin_qos); - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPlugin_serialized_sample_to_key( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData *sample, - struct RTICdrStream *stream, - RTIBool deserialize_encapsulation, - RTIBool deserialize_key, - void *endpoint_plugin_qos); - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPlugin_instance_to_key( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawDataKeyHolder *key, - const ConnextStaticRawData *instance); - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPlugin_key_to_instance( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData *instance, - const ConnextStaticRawDataKeyHolder *key); - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPlugin_instance_to_keyhash( - PRESTypePluginEndpointData endpoint_data, - DDS_KeyHash_t *keyhash, - const ConnextStaticRawData *instance); - - NDDSUSERDllExport extern RTIBool - ConnextStaticRawDataPlugin_serialized_sample_to_keyhash( - PRESTypePluginEndpointData endpoint_data, - struct RTICdrStream *stream, - DDS_KeyHash_t *keyhash, - RTIBool deserialize_encapsulation, - void *endpoint_plugin_qos); - - /* Plugin Functions */ - NDDSUSERDllExport extern struct PRESTypePlugin* - ConnextStaticRawDataPlugin_new(void); - - NDDSUSERDllExport - extern struct PRESTypePlugin * - ConnextStaticRawDataPlugin_new_external(struct DDS_TypeCode * external_type_code); - - NDDSUSERDllExport extern void - ConnextStaticRawDataPlugin_delete(struct PRESTypePlugin *); - +/* The type used to store keys for instances of type struct + * AnotherSimple. + * + * By default, this type is struct ConnextStaticRawData + * itself. However, if for some reason this choice is not practical for your + * system (e.g. if sizeof(struct ConnextStaticRawData) + * is very large), you may redefine this typedef in terms of another type of + * your choosing. HOWEVER, if you define the KeyHolder type to be something + * other than struct AnotherSimple, the + * following restriction applies: the key of struct + * ConnextStaticRawData must consist of a + * single field of your redefined KeyHolder type and that field must be the + * first field in struct ConnextStaticRawData. + */ +typedef class ConnextStaticRawData ConnextStaticRawDataKeyHolder; + +#define ConnextStaticRawDataPlugin_get_sample PRESTypePluginDefaultEndpointData_getSample +#define ConnextStaticRawDataPlugin_get_buffer PRESTypePluginDefaultEndpointData_getBuffer +#define ConnextStaticRawDataPlugin_return_buffer PRESTypePluginDefaultEndpointData_returnBuffer + +#define ConnextStaticRawDataPlugin_get_key PRESTypePluginDefaultEndpointData_getKey +#define ConnextStaticRawDataPlugin_return_key PRESTypePluginDefaultEndpointData_returnKey + +#define ConnextStaticRawDataPlugin_create_sample PRESTypePluginDefaultEndpointData_createSample +#define ConnextStaticRawDataPlugin_destroy_sample PRESTypePluginDefaultEndpointData_deleteSample + +/* -------------------------------------------------------------------------------------- + Support functions: + * -------------------------------------------------------------------------------------- */ + +NDDSUSERDllExport extern ConnextStaticRawData * +ConnextStaticRawDataPluginSupport_create_data_w_params( + const struct DDS_TypeAllocationParams_t * alloc_params); + +NDDSUSERDllExport extern ConnextStaticRawData * +ConnextStaticRawDataPluginSupport_create_data_ex(RTIBool allocate_pointers); + +NDDSUSERDllExport extern ConnextStaticRawData * +ConnextStaticRawDataPluginSupport_create_data(void); + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPluginSupport_copy_data( + ConnextStaticRawData * out, + const ConnextStaticRawData * in); + +NDDSUSERDllExport extern void +ConnextStaticRawDataPluginSupport_destroy_data_w_params( + ConnextStaticRawData * sample, + const struct DDS_TypeDeallocationParams_t * dealloc_params); + +NDDSUSERDllExport extern void +ConnextStaticRawDataPluginSupport_destroy_data_ex( + ConnextStaticRawData * sample, RTIBool deallocate_pointers); + +NDDSUSERDllExport extern void +ConnextStaticRawDataPluginSupport_destroy_data( + ConnextStaticRawData * sample); + +NDDSUSERDllExport extern void +ConnextStaticRawDataPluginSupport_print_data( + const ConnextStaticRawData * sample, + const char * desc, + unsigned int indent); + +NDDSUSERDllExport extern ConnextStaticRawData * +ConnextStaticRawDataPluginSupport_create_key_ex(RTIBool allocate_pointers); + +NDDSUSERDllExport extern ConnextStaticRawData * +ConnextStaticRawDataPluginSupport_create_key(void); + +NDDSUSERDllExport extern void +ConnextStaticRawDataPluginSupport_destroy_key_ex( + ConnextStaticRawDataKeyHolder * key, RTIBool deallocate_pointers); + +NDDSUSERDllExport extern void +ConnextStaticRawDataPluginSupport_destroy_key( + ConnextStaticRawDataKeyHolder * key); + +/* ---------------------------------------------------------------------------- + Callback functions: + * ---------------------------------------------------------------------------- */ + +NDDSUSERDllExport extern PRESTypePluginParticipantData +ConnextStaticRawDataPlugin_on_participant_attached( + void * registration_data, + const struct PRESTypePluginParticipantInfo * participant_info, + RTIBool top_level_registration, + void * container_plugin_context, + RTICdrTypeCode * typeCode); + +NDDSUSERDllExport extern void +ConnextStaticRawDataPlugin_on_participant_detached( + PRESTypePluginParticipantData participant_data); + +NDDSUSERDllExport extern PRESTypePluginEndpointData +ConnextStaticRawDataPlugin_on_endpoint_attached( + PRESTypePluginParticipantData participant_data, + const struct PRESTypePluginEndpointInfo * endpoint_info, + RTIBool top_level_registration, + void * container_plugin_context); + +NDDSUSERDllExport extern void +ConnextStaticRawDataPlugin_on_endpoint_detached( + PRESTypePluginEndpointData endpoint_data); + +NDDSUSERDllExport extern void +ConnextStaticRawDataPlugin_return_sample( + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData * sample, + void * handle); + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPlugin_copy_sample( + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData * out, + const ConnextStaticRawData * in); + +/* ---------------------------------------------------------------------------- + (De)Serialize functions: + * ------------------------------------------------------------------------- */ + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPlugin_serialize( + PRESTypePluginEndpointData endpoint_data, + const ConnextStaticRawData * sample, + struct RTICdrStream * stream, + RTIBool serialize_encapsulation, + RTIEncapsulationId encapsulation_id, + RTIBool serialize_sample, + void * endpoint_plugin_qos); + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPlugin_deserialize_sample( + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData * sample, + struct RTICdrStream * stream, + RTIBool deserialize_encapsulation, + RTIBool deserialize_sample, + void * endpoint_plugin_qos); + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPlugin_serialize_to_cdr_buffer( + char * buffer, + unsigned int * length, + const ConnextStaticRawData * sample); + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPlugin_deserialize( + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData ** sample, + RTIBool * drop_sample, + struct RTICdrStream * stream, + RTIBool deserialize_encapsulation, + RTIBool deserialize_sample, + void * endpoint_plugin_qos); + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPlugin_deserialize_from_cdr_buffer( + ConnextStaticRawData * sample, + const char * buffer, + unsigned int length); + +NDDSUSERDllExport extern DDS_ReturnCode_t +ConnextStaticRawDataPlugin_data_to_string( + const ConnextStaticRawData * sample, + char * str, + DDS_UnsignedLong * str_size, + const struct DDS_PrintFormatProperty * property); + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPlugin_skip( + PRESTypePluginEndpointData endpoint_data, + struct RTICdrStream * stream, + RTIBool skip_encapsulation, + RTIBool skip_sample, + void * endpoint_plugin_qos); + +NDDSUSERDllExport extern unsigned int +ConnextStaticRawDataPlugin_get_serialized_sample_max_size_ex( + PRESTypePluginEndpointData endpoint_data, + RTIBool * overflow, + RTIBool include_encapsulation, + RTIEncapsulationId encapsulation_id, + unsigned int current_alignment); + +NDDSUSERDllExport extern unsigned int +ConnextStaticRawDataPlugin_get_serialized_sample_max_size( + PRESTypePluginEndpointData endpoint_data, + RTIBool include_encapsulation, + RTIEncapsulationId encapsulation_id, + unsigned int current_alignment); + +NDDSUSERDllExport extern unsigned int +ConnextStaticRawDataPlugin_get_serialized_sample_min_size( + PRESTypePluginEndpointData endpoint_data, + RTIBool include_encapsulation, + RTIEncapsulationId encapsulation_id, + unsigned int current_alignment); + +NDDSUSERDllExport extern unsigned int +ConnextStaticRawDataPlugin_get_serialized_sample_size( + PRESTypePluginEndpointData endpoint_data, + RTIBool include_encapsulation, + RTIEncapsulationId encapsulation_id, + unsigned int current_alignment, + const ConnextStaticRawData * sample); + +/* -------------------------------------------------------------------------------------- + Key Management functions: + * -------------------------------------------------------------------------------------- */ +NDDSUSERDllExport extern PRESTypePluginKeyKind +ConnextStaticRawDataPlugin_get_key_kind(void); + +NDDSUSERDllExport extern unsigned int +ConnextStaticRawDataPlugin_get_serialized_key_max_size_ex( + PRESTypePluginEndpointData endpoint_data, + RTIBool * overflow, + RTIBool include_encapsulation, + RTIEncapsulationId encapsulation_id, + unsigned int current_alignment); + +NDDSUSERDllExport extern unsigned int +ConnextStaticRawDataPlugin_get_serialized_key_max_size( + PRESTypePluginEndpointData endpoint_data, + RTIBool include_encapsulation, + RTIEncapsulationId encapsulation_id, + unsigned int current_alignment); + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPlugin_serialize_key( + PRESTypePluginEndpointData endpoint_data, + const ConnextStaticRawData * sample, + struct RTICdrStream * stream, + RTIBool serialize_encapsulation, + RTIEncapsulationId encapsulation_id, + RTIBool serialize_key, + void * endpoint_plugin_qos); + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPlugin_deserialize_key_sample( + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData * sample, + struct RTICdrStream * stream, + RTIBool deserialize_encapsulation, + RTIBool deserialize_key, + void * endpoint_plugin_qos); + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPlugin_deserialize_key( + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData ** sample, + RTIBool * drop_sample, + struct RTICdrStream * stream, + RTIBool deserialize_encapsulation, + RTIBool deserialize_key, + void * endpoint_plugin_qos); + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPlugin_serialized_sample_to_key( + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData * sample, + struct RTICdrStream * stream, + RTIBool deserialize_encapsulation, + RTIBool deserialize_key, + void * endpoint_plugin_qos); + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPlugin_instance_to_key( + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawDataKeyHolder * key, + const ConnextStaticRawData * instance); + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPlugin_key_to_instance( + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData * instance, + const ConnextStaticRawDataKeyHolder * key); + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPlugin_instance_to_keyhash( + PRESTypePluginEndpointData endpoint_data, + DDS_KeyHash_t * keyhash, + const ConnextStaticRawData * instance); + +NDDSUSERDllExport extern RTIBool +ConnextStaticRawDataPlugin_serialized_sample_to_keyhash( + PRESTypePluginEndpointData endpoint_data, + struct RTICdrStream * stream, + DDS_KeyHash_t * keyhash, + RTIBool deserialize_encapsulation, + void * endpoint_plugin_qos); + +/* Plugin Functions */ +NDDSUSERDllExport extern struct PRESTypePlugin * +ConnextStaticRawDataPlugin_new(void); + +NDDSUSERDllExport +extern struct PRESTypePlugin * +ConnextStaticRawDataPlugin_new_external(struct DDS_TypeCode * external_type_code); + +NDDSUSERDllExport extern void +ConnextStaticRawDataPlugin_delete(struct PRESTypePlugin *); } #if (defined(RTI_WIN32) || defined (RTI_WINCE)) && defined(NDDS_USER_DLL_EXPORT) @@ -338,4 +338,4 @@ extern "C" { #define NDDSUSERDllExport #endif -#endif /* ConnextStaticRawDataPlugin_1689213465_h */ +#endif // RMW_CONNEXT_CPP__CONNEXT_STATIC_RAW_DATA_PLUGIN_HPP_ diff --git a/rmw_connext_cpp/include/rmw_connext_cpp/connext_static_raw_data_support.hpp b/rmw_connext_cpp/include/rmw_connext_cpp/connext_static_raw_data_support.hpp index 1b6570b9..03fd88e5 100644 --- a/rmw_connext_cpp/include/rmw_connext_cpp/connext_static_raw_data_support.hpp +++ b/rmw_connext_cpp/include/rmw_connext_cpp/connext_static_raw_data_support.hpp @@ -7,8 +7,8 @@ For more information, type 'rtiddsgen -help' at a command shell or consult the RTI Connext manual. */ -#ifndef ConnextStaticRawDataSupport_1689213465_h -#define ConnextStaticRawDataSupport_1689213465_h +#ifndef RMW_CONNEXT_CPP__CONNEXT_STATIC_RAW_DATA_SUPPORT_HPP_ +#define RMW_CONNEXT_CPP__CONNEXT_STATIC_RAW_DATA_SUPPORT_HPP_ /* Uses */ #include "rmw_connext_cpp/connext_static_raw_data.hpp" @@ -19,9 +19,9 @@ or consult the RTI Connext manual. #if (defined(RTI_WIN32) || defined (RTI_WINCE)) && defined(NDDS_USER_DLL_EXPORT) -class __declspec(dllimport) DDSTypeSupport; -class __declspec(dllimport) DDSDataWriter; -class __declspec(dllimport) DDSDataReader; +class __declspec (dllimport) DDSTypeSupport; +class __declspec (dllimport) DDSDataWriter; +class __declspec (dllimport) DDSDataReader; #endif @@ -49,75 +49,83 @@ class NDDSUSERDllExport DDSCPPDllExport ConnextStaticRawDataTypeSupport : public ConnextStaticRawDataTypeSupport(bool osrf) { (void) osrf; - }; + } ~ConnextStaticRawDataTypeSupport(); static DDS_ReturnCode_t register_type( - DDSDomainParticipant* participant, - const char* type_name = "ConnextStaticRawData"); + DDSDomainParticipant * participant, + const char * type_name = "ConnextStaticRawData"); static DDS_ReturnCode_t unregister_type( - DDSDomainParticipant* participant, - const char* type_name = "ConnextStaticRawData"); + DDSDomainParticipant * participant, + const char * type_name = "ConnextStaticRawData"); - static const char* get_type_name(); + static const char * get_type_name(); - static ConnextStaticRawData* create_data_ex(DDS_Boolean allocatePointers); + static ConnextStaticRawData * create_data_ex(DDS_Boolean allocatePointers); - static ConnextStaticRawData* create_data( - const DDS_TypeAllocationParams_t & alloc_params = - DDS_TYPE_ALLOCATION_PARAMS_DEFAULT); + static ConnextStaticRawData * create_data( + const DDS_TypeAllocationParams_t & alloc_params = + DDS_TYPE_ALLOCATION_PARAMS_DEFAULT); - static DDS_ReturnCode_t delete_data_ex(ConnextStaticRawData* a_data, - DDS_Boolean deletePointers); + static DDS_ReturnCode_t delete_data_ex( + ConnextStaticRawData * a_data, + DDS_Boolean deletePointers); static DDS_ReturnCode_t delete_data( - ConnextStaticRawData* a_data, - const DDS_TypeDeallocationParams_t & dealloc_params = - DDS_TYPE_DEALLOCATION_PARAMS_DEFAULT); + ConnextStaticRawData * a_data, + const DDS_TypeDeallocationParams_t & dealloc_params = + DDS_TYPE_DEALLOCATION_PARAMS_DEFAULT); - static void print_data(const ConnextStaticRawData* a_data); + static void print_data(const ConnextStaticRawData * a_data); - static DDS_ReturnCode_t copy_data(ConnextStaticRawData* dst_data, const ConnextStaticRawData* src_data); + static DDS_ReturnCode_t copy_data( + ConnextStaticRawData * dst_data, const ConnextStaticRawData * src_data); - static DDS_ReturnCode_t initialize_data_ex(ConnextStaticRawData* a_data, - DDS_Boolean allocatePointers); + static DDS_ReturnCode_t initialize_data_ex( + ConnextStaticRawData * a_data, + DDS_Boolean allocatePointers); static DDS_ReturnCode_t initialize_data( - ConnextStaticRawData* a_data, - const DDS_TypeAllocationParams_t & alloc_params = - DDS_TYPE_ALLOCATION_PARAMS_DEFAULT); + ConnextStaticRawData * a_data, + const DDS_TypeAllocationParams_t & alloc_params = + DDS_TYPE_ALLOCATION_PARAMS_DEFAULT); + + static DDS_ReturnCode_t finalize_data_ex( + ConnextStaticRawData * a_data, + DDS_Boolean deletePointers); - static DDS_ReturnCode_t finalize_data_ex(ConnextStaticRawData* a_data, - DDS_Boolean deletePointers); static DDS_ReturnCode_t finalize_data( - ConnextStaticRawData* a_data, - const DDS_TypeDeallocationParams_t & dealloc_params = - DDS_TYPE_DEALLOCATION_PARAMS_DEFAULT); + ConnextStaticRawData * a_data, + const DDS_TypeDeallocationParams_t & dealloc_params = + DDS_TYPE_DEALLOCATION_PARAMS_DEFAULT); + + DDSDataReader * create_datareaderI(DDSDataReader * dataReader); + + DDS_ReturnCode_t destroy_datareaderI(DDSDataReader * dataReader); + + DDSDataWriter * create_datawriterI(DDSDataWriter * dataWriter); - DDSDataReader* create_datareaderI(DDSDataReader* dataReader); - DDS_ReturnCode_t destroy_datareaderI(DDSDataReader* dataReader); - DDSDataWriter* create_datawriterI(DDSDataWriter* dataWriter); - DDS_ReturnCode_t destroy_datawriterI(DDSDataWriter* dataWriter); + DDS_ReturnCode_t destroy_datawriterI(DDSDataWriter * dataWriter); - static DDS_TypeCode* get_typecode(); + static DDS_TypeCode * get_typecode(); static DDS_ReturnCode_t serialize_data_to_cdr_buffer( - char * buffer, - unsigned int & length, - const ConnextStaticRawData *a_data); + char * buffer, + unsigned int & length, + const ConnextStaticRawData * a_data); static DDS_ReturnCode_t deserialize_data_from_cdr_buffer( - ConnextStaticRawData *a_data, - const char * buffer, - unsigned int length); + ConnextStaticRawData * a_data, + const char * buffer, + unsigned int length); static DDS_ReturnCode_t data_to_string( - ConnextStaticRawData *sample, - char *str, - DDS_UnsignedLong& str_size, - const DDS_PrintFormatProperty& property); + ConnextStaticRawData * sample, + char * str, + DDS_UnsignedLong & str_size, + const DDS_PrintFormatProperty & property); static void finalize(); @@ -142,4 +150,4 @@ ConnextStaticRawDataSupport_register_external_type( #define NDDSUSERDllExport #endif -#endif /* ConnextStaticRawDataSupport_1689213465_h */ +#endif // RMW_CONNEXT_CPP__CONNEXT_STATIC_RAW_DATA_SUPPORT_HPP_ diff --git a/rmw_connext_cpp/src/connext_static_raw_data.cpp b/rmw_connext_cpp/src/connext_static_raw_data.cpp index 307ec34c..91db6bdd 100644 --- a/rmw_connext_cpp/src/connext_static_raw_data.cpp +++ b/rmw_connext_cpp/src/connext_static_raw_data.cpp @@ -19,263 +19,263 @@ or consult the RTI Connext manual. #include "cdr/cdr_type.h" #endif -#ifndef osapi_heap_h #include "osapi/osapi_heap.h" #endif -#else -#include "ndds_standalone_type.h" -#endif #include "rmw_connext_cpp/connext_static_raw_data.hpp" #include /* ========================================================================= */ -const char *ConnextStaticRawDataTYPENAME = "ConnextStaticRawData"; +const char * ConnextStaticRawDataTYPENAME = "ConnextStaticRawData"; -DDS_TypeCode* ConnextStaticRawData_get_typecode() +DDS_TypeCode * ConnextStaticRawData_get_typecode() { - static RTIBool is_initialized = RTI_FALSE; - - static DDS_TypeCode ConnextStaticRawData_g_tc_key_hash_array =DDS_INITIALIZE_ARRAY_TYPECODE(1,(KEY_HASH_LENGTH_16), NULL,NULL); - static DDS_TypeCode ConnextStaticRawData_g_tc_serialized_key_sequence = DDS_INITIALIZE_SEQUENCE_TYPECODE(RTI_INT32_MAX,NULL); - static DDS_TypeCode ConnextStaticRawData_g_tc_serialized_data_sequence = DDS_INITIALIZE_SEQUENCE_TYPECODE(RTI_INT32_MAX,NULL); - static DDS_TypeCode_Member ConnextStaticRawData_g_tc_members[3]= + static RTIBool is_initialized = RTI_FALSE; + + static DDS_TypeCode ConnextStaticRawData_g_tc_key_hash_array = + DDS_INITIALIZE_ARRAY_TYPECODE(1, (KEY_HASH_LENGTH_16), NULL, NULL); + static DDS_TypeCode ConnextStaticRawData_g_tc_serialized_key_sequence = + DDS_INITIALIZE_SEQUENCE_TYPECODE(RTI_INT32_MAX, NULL); + static DDS_TypeCode ConnextStaticRawData_g_tc_serialized_data_sequence = + DDS_INITIALIZE_SEQUENCE_TYPECODE(RTI_INT32_MAX, NULL); + static DDS_TypeCode_Member ConnextStaticRawData_g_tc_members[3] = + { { - - { - (char *)"key_hash",/* Member name */ - { - 0,/* Representation ID */ - DDS_BOOLEAN_FALSE,/* Is a pointer? */ - -1, /* Bitfield bits */ - NULL/* Member type code is assigned later */ - }, - 0, /* Ignored */ - 0, /* Ignored */ - 0, /* Ignored */ - NULL, /* Ignored */ - RTI_CDR_KEY_MEMBER , /* Is a key? */ - DDS_PUBLIC_MEMBER,/* Member visibility */ - 1, - NULL/* Ignored */ - }, - { - (char *)"serialized_key",/* Member name */ - { - 1,/* Representation ID */ - DDS_BOOLEAN_FALSE,/* Is a pointer? */ - -1, /* Bitfield bits */ - NULL/* Member type code is assigned later */ - }, - 0, /* Ignored */ - 0, /* Ignored */ - 0, /* Ignored */ - NULL, /* Ignored */ - RTI_CDR_REQUIRED_MEMBER, /* Is a key? */ - DDS_PUBLIC_MEMBER,/* Member visibility */ - 1, - NULL/* Ignored */ - }, - { - (char *)"serialized_data",/* Member name */ - { - 2,/* Representation ID */ - DDS_BOOLEAN_FALSE,/* Is a pointer? */ - -1, /* Bitfield bits */ - NULL/* Member type code is assigned later */ - }, - 0, /* Ignored */ - 0, /* Ignored */ - 0, /* Ignored */ - NULL, /* Ignored */ - RTI_CDR_REQUIRED_MEMBER, /* Is a key? */ - DDS_PUBLIC_MEMBER,/* Member visibility */ - 1, - NULL/* Ignored */ - } - }; - - static DDS_TypeCode ConnextStaticRawData_g_tc = - {{ - DDS_TK_STRUCT,/* Kind */ - DDS_BOOLEAN_FALSE, /* Ignored */ - -1, /*Ignored*/ - (char *)"ConnextStaticRawData", /* Name */ - NULL, /* Ignored */ - 0, /* Ignored */ - 0, /* Ignored */ - NULL, /* Ignored */ - 3, /* Number of members */ - ConnextStaticRawData_g_tc_members, /* Members */ - DDS_VM_NONE /* Ignored */ - }}; /* Type code for ConnextStaticRawData*/ - - if (is_initialized) { - return &ConnextStaticRawData_g_tc; + (char *)"key_hash", /* Member name */ // NOLINT + { + 0, /* Representation ID */ + DDS_BOOLEAN_FALSE, /* Is a pointer? */ + -1, /* Bitfield bits */ + NULL /* Member type code is assigned later */ + }, + 0, /* Ignored */ + 0, /* Ignored */ + 0, /* Ignored */ + NULL, /* Ignored */ + RTI_CDR_KEY_MEMBER, /* Is a key? */ + DDS_PUBLIC_MEMBER, /* Member visibility */ + 1, + NULL /* Ignored */ + }, + { + (char *)"serialized_key", /* Member name */ // NOLINT + { + 1, /* Representation ID */ + DDS_BOOLEAN_FALSE, /* Is a pointer? */ + -1, /* Bitfield bits */ + NULL /* Member type code is assigned later */ + }, + 0, /* Ignored */ + 0, /* Ignored */ + 0, /* Ignored */ + NULL, /* Ignored */ + RTI_CDR_REQUIRED_MEMBER, /* Is a key? */ + DDS_PUBLIC_MEMBER, /* Member visibility */ + 1, + NULL /* Ignored */ + }, + { + (char *)"serialized_data", /* Member name */ // NOLINT + { + 2, /* Representation ID */ + DDS_BOOLEAN_FALSE, /* Is a pointer? */ + -1, /* Bitfield bits */ + NULL /* Member type code is assigned later */ + }, + 0, /* Ignored */ + 0, /* Ignored */ + 0, /* Ignored */ + NULL, /* Ignored */ + RTI_CDR_REQUIRED_MEMBER, /* Is a key? */ + DDS_PUBLIC_MEMBER, /* Member visibility */ + 1, + NULL /* Ignored */ } + }; + + static DDS_TypeCode ConnextStaticRawData_g_tc = + {{ + DDS_TK_STRUCT, /* Kind */ + DDS_BOOLEAN_FALSE, /* Ignored */ + -1, /*Ignored*/ + (char *)"ConnextStaticRawData", /* Name */ // NOLINT + NULL, /* Ignored */ + 0, /* Ignored */ + 0, /* Ignored */ + NULL, /* Ignored */ + 3, /* Number of members */ + ConnextStaticRawData_g_tc_members, /* Members */ + DDS_VM_NONE /* Ignored */ + }}; /* Type code for ConnextStaticRawData*/ + + if (is_initialized) { + return &ConnextStaticRawData_g_tc; + } - ConnextStaticRawData_g_tc_key_hash_array._data._typeCode =(RTICdrTypeCode *)&DDS_g_tc_octet; + ConnextStaticRawData_g_tc_key_hash_array._data._typeCode = + (RTICdrTypeCode *)&DDS_g_tc_octet; // NOLINT - ConnextStaticRawData_g_tc_serialized_key_sequence._data._typeCode = (RTICdrTypeCode *)&DDS_g_tc_octet; + ConnextStaticRawData_g_tc_serialized_key_sequence._data._typeCode = + (RTICdrTypeCode *)&DDS_g_tc_octet; // NOLINT - ConnextStaticRawData_g_tc_serialized_data_sequence._data._typeCode = (RTICdrTypeCode *)&DDS_g_tc_octet; + ConnextStaticRawData_g_tc_serialized_data_sequence._data._typeCode = + (RTICdrTypeCode *)&DDS_g_tc_octet; // NOLINT - ConnextStaticRawData_g_tc_members[0]._representation._typeCode = (RTICdrTypeCode *)& ConnextStaticRawData_g_tc_key_hash_array; - ConnextStaticRawData_g_tc_members[1]._representation._typeCode = (RTICdrTypeCode *)& ConnextStaticRawData_g_tc_serialized_key_sequence; - ConnextStaticRawData_g_tc_members[2]._representation._typeCode = (RTICdrTypeCode *)& ConnextStaticRawData_g_tc_serialized_data_sequence; + ConnextStaticRawData_g_tc_members[0]._representation._typeCode = + (RTICdrTypeCode *)&ConnextStaticRawData_g_tc_key_hash_array; // NOLINT + ConnextStaticRawData_g_tc_members[1]._representation._typeCode = + (RTICdrTypeCode *)&ConnextStaticRawData_g_tc_serialized_key_sequence; // NOLINT + ConnextStaticRawData_g_tc_members[2]._representation._typeCode = + (RTICdrTypeCode *)&ConnextStaticRawData_g_tc_serialized_data_sequence; // NOLINT - is_initialized = RTI_TRUE; + is_initialized = RTI_TRUE; - return &ConnextStaticRawData_g_tc; + return &ConnextStaticRawData_g_tc; } RTIBool ConnextStaticRawData_initialize( - ConnextStaticRawData* sample) { - return ConnextStaticRawData_initialize_ex(sample,RTI_TRUE,RTI_TRUE); + ConnextStaticRawData * sample) +{ + return ConnextStaticRawData_initialize_ex(sample, RTI_TRUE, RTI_TRUE); } RTIBool ConnextStaticRawData_initialize_ex( - ConnextStaticRawData* sample,RTIBool allocatePointers, RTIBool allocateMemory) + ConnextStaticRawData * sample, RTIBool allocatePointers, RTIBool allocateMemory) { - - struct DDS_TypeAllocationParams_t allocParams = + struct DDS_TypeAllocationParams_t allocParams = DDS_TYPE_ALLOCATION_PARAMS_DEFAULT; - allocParams.allocate_pointers = (DDS_Boolean)allocatePointers; - allocParams.allocate_memory = (DDS_Boolean)allocateMemory; - - return ConnextStaticRawData_initialize_w_params( - sample,&allocParams); + allocParams.allocate_pointers = (DDS_Boolean)allocatePointers; + allocParams.allocate_memory = (DDS_Boolean)allocateMemory; + return ConnextStaticRawData_initialize_w_params( + sample, &allocParams); } RTIBool ConnextStaticRawData_initialize_w_params( - ConnextStaticRawData* sample, const struct DDS_TypeAllocationParams_t * allocParams) + ConnextStaticRawData * sample, const struct DDS_TypeAllocationParams_t * allocParams) { - - void* buffer = NULL; - if (buffer) {} /* To avoid warnings */ - - if (sample == NULL) { - return RTI_FALSE; + void * buffer = NULL; + if (buffer) {} /* To avoid warnings */ + + if (sample == NULL) { + return RTI_FALSE; + } + if (allocParams == NULL) { + return RTI_FALSE; + } + + if (!RTICdrType_initArray( + sample->key_hash, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_SIZE)) + { + return RTI_FALSE; + } + if (allocParams->allocate_memory) { + DDS_OctetSeq_initialize(&sample->serialized_key); + DDS_OctetSeq_set_absolute_maximum(&sample->serialized_key, RTI_INT32_MAX); + if (!DDS_OctetSeq_set_maximum(&sample->serialized_key, (0))) { + return RTI_FALSE; } - if (allocParams == NULL) { - return RTI_FALSE; + } else { + DDS_OctetSeq_set_length(&sample->serialized_key, 0); + } + if (allocParams->allocate_memory) { + DDS_OctetSeq_initialize(&sample->serialized_data); + DDS_OctetSeq_set_absolute_maximum(&sample->serialized_data, RTI_INT32_MAX); + if (!DDS_OctetSeq_set_maximum(&sample->serialized_data, (0))) { + return RTI_FALSE; } - - if (!RTICdrType_initArray( - sample->key_hash, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_SIZE)) { - return RTI_FALSE; - } - if (allocParams->allocate_memory) { - DDS_OctetSeq_initialize(&sample->serialized_key ); - DDS_OctetSeq_set_absolute_maximum(&sample->serialized_key , RTI_INT32_MAX); - if (!DDS_OctetSeq_set_maximum(&sample->serialized_key , (0))) { - return RTI_FALSE; - } - } else { - DDS_OctetSeq_set_length(&sample->serialized_key, 0); - } - if (allocParams->allocate_memory) { - DDS_OctetSeq_initialize(&sample->serialized_data ); - DDS_OctetSeq_set_absolute_maximum(&sample->serialized_data , RTI_INT32_MAX); - if (!DDS_OctetSeq_set_maximum(&sample->serialized_data , (0))) { - return RTI_FALSE; - } - } else { - DDS_OctetSeq_set_length(&sample->serialized_data, 0); - } - return RTI_TRUE; + } else { + DDS_OctetSeq_set_length(&sample->serialized_data, 0); + } + return RTI_TRUE; } void ConnextStaticRawData_finalize( - ConnextStaticRawData* sample) + ConnextStaticRawData * sample) { - - ConnextStaticRawData_finalize_ex(sample,RTI_TRUE); + ConnextStaticRawData_finalize_ex(sample, RTI_TRUE); } void ConnextStaticRawData_finalize_ex( - ConnextStaticRawData* sample,RTIBool deletePointers) + ConnextStaticRawData * sample, RTIBool deletePointers) { - struct DDS_TypeDeallocationParams_t deallocParams = + struct DDS_TypeDeallocationParams_t deallocParams = DDS_TYPE_DEALLOCATION_PARAMS_DEFAULT; - if (sample==NULL) { - return; - } + if (sample == NULL) { + return; + } - deallocParams.delete_pointers = (DDS_Boolean)deletePointers; + deallocParams.delete_pointers = (DDS_Boolean)deletePointers; - ConnextStaticRawData_finalize_w_params( - sample,&deallocParams); + ConnextStaticRawData_finalize_w_params( + sample, &deallocParams); } void ConnextStaticRawData_finalize_w_params( - ConnextStaticRawData* sample,const struct DDS_TypeDeallocationParams_t * deallocParams) + ConnextStaticRawData * sample, const struct DDS_TypeDeallocationParams_t * deallocParams) { + if (sample == NULL) { + return; + } - if (sample==NULL) { - return; - } - - if (deallocParams == NULL) { - return; - } + if (deallocParams == NULL) { + return; + } - DDS_OctetSeq_finalize(&sample->serialized_key); - - DDS_OctetSeq_finalize(&sample->serialized_data); + DDS_OctetSeq_finalize(&sample->serialized_key); + DDS_OctetSeq_finalize(&sample->serialized_data); } void ConnextStaticRawData_finalize_optional_members( - ConnextStaticRawData* sample, RTIBool deletePointers) + ConnextStaticRawData * sample, RTIBool deletePointers) { - struct DDS_TypeDeallocationParams_t deallocParamsTmp = + struct DDS_TypeDeallocationParams_t deallocParamsTmp = DDS_TYPE_DEALLOCATION_PARAMS_DEFAULT; - struct DDS_TypeDeallocationParams_t * deallocParams = + struct DDS_TypeDeallocationParams_t * deallocParams = &deallocParamsTmp; - if (sample==NULL) { - return; - } - if (deallocParams) {} /* To avoid warnings */ - - deallocParamsTmp.delete_pointers = (DDS_Boolean)deletePointers; - deallocParamsTmp.delete_optional_members = DDS_BOOLEAN_TRUE; + if (sample == NULL) { + return; + } + if (deallocParams) {} /* To avoid warnings */ + deallocParamsTmp.delete_pointers = (DDS_Boolean)deletePointers; + deallocParamsTmp.delete_optional_members = DDS_BOOLEAN_TRUE; } RTIBool ConnextStaticRawData_copy( - ConnextStaticRawData* dst, - const ConnextStaticRawData* src) + ConnextStaticRawData * dst, + const ConnextStaticRawData * src) { - try { - - if (dst == NULL || src == NULL) { - return RTI_FALSE; - } - - if (!RTICdrType_copyArray( - dst->key_hash ,src->key_hash,((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_SIZE)) { - return RTI_FALSE; - } - if (!DDS_OctetSeq_copy(&dst->serialized_key , - &src->serialized_key )) { - return RTI_FALSE; - } - if (!DDS_OctetSeq_copy(&dst->serialized_data , - &src->serialized_data )) { - return RTI_FALSE; - } - - return RTI_TRUE; - - } catch (std::bad_alloc&) { - return RTI_FALSE; + try { + if (dst == NULL || src == NULL) { + return RTI_FALSE; } + + if (!RTICdrType_copyArray( + dst->key_hash, src->key_hash, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_SIZE)) + { + return RTI_FALSE; + } + if (!DDS_OctetSeq_copy(&dst->serialized_key, + &src->serialized_key)) + { + return RTI_FALSE; + } + if (!DDS_OctetSeq_copy(&dst->serialized_data, + &src->serialized_data)) + { + return RTI_FALSE; + } + + return RTI_TRUE; + } catch (std::bad_alloc &) { + return RTI_FALSE; + } } /** diff --git a/rmw_connext_cpp/src/connext_static_raw_data_plugin.cpp b/rmw_connext_cpp/src/connext_static_raw_data_plugin.cpp index 75861dbb..ae4d9c2b 100644 --- a/rmw_connext_cpp/src/connext_static_raw_data_plugin.cpp +++ b/rmw_connext_cpp/src/connext_static_raw_data_plugin.cpp @@ -62,176 +62,173 @@ or consult the RTI Connext manual. Support functions: * -------------------------------------------------------------------------- */ -ConnextStaticRawData* +ConnextStaticRawData * ConnextStaticRawDataPluginSupport_create_data_w_params( - const struct DDS_TypeAllocationParams_t * alloc_params) + const struct DDS_TypeAllocationParams_t * alloc_params) { - ConnextStaticRawData *sample = NULL; - - sample = new (std::nothrow) ConnextStaticRawData ; - if (sample == NULL) { - return NULL; - } - - if (!ConnextStaticRawData_initialize_w_params(sample,alloc_params)) { - delete sample; - sample=NULL; - } - return sample; + ConnextStaticRawData * sample = NULL; + + sample = new (std::nothrow) ConnextStaticRawData; + if (sample == NULL) { + return NULL; + } + + if (!ConnextStaticRawData_initialize_w_params(sample, alloc_params)) { + delete sample; + sample = NULL; + } + return sample; } ConnextStaticRawData * ConnextStaticRawDataPluginSupport_create_data_ex(RTIBool allocate_pointers) { - ConnextStaticRawData *sample = NULL; + ConnextStaticRawData * sample = NULL; - sample = new (std::nothrow) ConnextStaticRawData ; + sample = new (std::nothrow) ConnextStaticRawData; - if(sample == NULL) { - return NULL; - } + if (sample == NULL) { + return NULL; + } - if (!ConnextStaticRawData_initialize_ex(sample,allocate_pointers, RTI_TRUE)) { - delete sample; - sample=NULL; - } + if (!ConnextStaticRawData_initialize_ex(sample, allocate_pointers, RTI_TRUE)) { + delete sample; + sample = NULL; + } - return sample; + return sample; } ConnextStaticRawData * ConnextStaticRawDataPluginSupport_create_data(void) { - return ConnextStaticRawDataPluginSupport_create_data_ex(RTI_TRUE); + return ConnextStaticRawDataPluginSupport_create_data_ex(RTI_TRUE); } void ConnextStaticRawDataPluginSupport_destroy_data_w_params( - ConnextStaticRawData *sample, - const struct DDS_TypeDeallocationParams_t * dealloc_params) { - - ConnextStaticRawData_finalize_w_params(sample,dealloc_params); + ConnextStaticRawData * sample, + const struct DDS_TypeDeallocationParams_t * dealloc_params) +{ + ConnextStaticRawData_finalize_w_params(sample, dealloc_params); - delete sample; - sample=NULL; + delete sample; + sample = NULL; } void ConnextStaticRawDataPluginSupport_destroy_data_ex( - ConnextStaticRawData *sample,RTIBool deallocate_pointers) { - - ConnextStaticRawData_finalize_ex(sample,deallocate_pointers); + ConnextStaticRawData * sample, RTIBool deallocate_pointers) +{ + ConnextStaticRawData_finalize_ex(sample, deallocate_pointers); - delete sample; - sample=NULL; + delete sample; + sample = NULL; } void ConnextStaticRawDataPluginSupport_destroy_data( - ConnextStaticRawData *sample) { - - ConnextStaticRawDataPluginSupport_destroy_data_ex(sample,RTI_TRUE); - + ConnextStaticRawData * sample) +{ + ConnextStaticRawDataPluginSupport_destroy_data_ex(sample, RTI_TRUE); } RTIBool ConnextStaticRawDataPluginSupport_copy_data( - ConnextStaticRawData *dst, - const ConnextStaticRawData *src) + ConnextStaticRawData * dst, + const ConnextStaticRawData * src) { - return ConnextStaticRawData_copy(dst,(const ConnextStaticRawData*) src); + return ConnextStaticRawData_copy(dst, (const ConnextStaticRawData *) src); } void ConnextStaticRawDataPluginSupport_print_data( - const ConnextStaticRawData *sample, - const char *desc, - unsigned int indent_level) + const ConnextStaticRawData * sample, + const char * desc, + unsigned int indent_level) { + RTICdrType_printIndent(indent_level); - RTICdrType_printIndent(indent_level); + if (desc != NULL) { + RTILog_debug("%s:\n", desc); + } else { + RTILog_debug("\n"); + } - if (desc != NULL) { - RTILog_debug("%s:\n", desc); - } else { - RTILog_debug("\n"); - } + if (sample == NULL) { + RTILog_debug("NULL\n"); + return; + } - if (sample == NULL) { - RTILog_debug("NULL\n"); - return; - } + RTICdrType_printArray( + sample->key_hash, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_SIZE, + (RTICdrTypePrintFunction)RTICdrType_printOctet, + "key_hash", indent_level + 1); + if (DDS_OctetSeq_get_contiguous_bufferI(&sample->serialized_key) != NULL) { RTICdrType_printArray( - sample->key_hash, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_SIZE, - (RTICdrTypePrintFunction)RTICdrType_printOctet, - "key_hash", indent_level + 1); - - if (DDS_OctetSeq_get_contiguous_bufferI(&sample->serialized_key) != NULL) { - RTICdrType_printArray( - DDS_OctetSeq_get_contiguous_bufferI(&sample->serialized_key), - DDS_OctetSeq_get_length(&sample->serialized_key), - RTI_CDR_OCTET_SIZE, - (RTICdrTypePrintFunction)RTICdrType_printOctet, - "serialized_key", indent_level + 1); - } else { - RTICdrType_printPointerArray( - DDS_OctetSeq_get_discontiguous_bufferI(&sample->serialized_key), - DDS_OctetSeq_get_length(&sample->serialized_key ), - (RTICdrTypePrintFunction)RTICdrType_printOctet, - "serialized_key", indent_level + 1); - } - - if (DDS_OctetSeq_get_contiguous_bufferI(&sample->serialized_data) != NULL) { - RTICdrType_printArray( - DDS_OctetSeq_get_contiguous_bufferI(&sample->serialized_data), - DDS_OctetSeq_get_length(&sample->serialized_data), - RTI_CDR_OCTET_SIZE, - (RTICdrTypePrintFunction)RTICdrType_printOctet, - "serialized_data", indent_level + 1); - } else { - RTICdrType_printPointerArray( - DDS_OctetSeq_get_discontiguous_bufferI(&sample->serialized_data), - DDS_OctetSeq_get_length(&sample->serialized_data ), - (RTICdrTypePrintFunction)RTICdrType_printOctet, - "serialized_data", indent_level + 1); - } - + DDS_OctetSeq_get_contiguous_bufferI(&sample->serialized_key), + DDS_OctetSeq_get_length(&sample->serialized_key), + RTI_CDR_OCTET_SIZE, + (RTICdrTypePrintFunction)RTICdrType_printOctet, + "serialized_key", indent_level + 1); + } else { + RTICdrType_printPointerArray( + DDS_OctetSeq_get_discontiguous_bufferI(&sample->serialized_key), + DDS_OctetSeq_get_length(&sample->serialized_key), + (RTICdrTypePrintFunction)RTICdrType_printOctet, + "serialized_key", indent_level + 1); + } + + if (DDS_OctetSeq_get_contiguous_bufferI(&sample->serialized_data) != NULL) { + RTICdrType_printArray( + DDS_OctetSeq_get_contiguous_bufferI(&sample->serialized_data), + DDS_OctetSeq_get_length(&sample->serialized_data), + RTI_CDR_OCTET_SIZE, + (RTICdrTypePrintFunction)RTICdrType_printOctet, + "serialized_data", indent_level + 1); + } else { + RTICdrType_printPointerArray( + DDS_OctetSeq_get_discontiguous_bufferI(&sample->serialized_data), + DDS_OctetSeq_get_length(&sample->serialized_data), + (RTICdrTypePrintFunction)RTICdrType_printOctet, + "serialized_data", indent_level + 1); + } } + ConnextStaticRawData * -ConnextStaticRawDataPluginSupport_create_key_ex(RTIBool allocate_pointers){ - ConnextStaticRawData *key = NULL; +ConnextStaticRawDataPluginSupport_create_key_ex(RTIBool allocate_pointers) +{ + ConnextStaticRawData * key = NULL; - key = new (std::nothrow) ConnextStaticRawDataKeyHolder ; + key = new (std::nothrow) ConnextStaticRawDataKeyHolder; - ConnextStaticRawData_initialize_ex(key,allocate_pointers, RTI_TRUE); + ConnextStaticRawData_initialize_ex(key, allocate_pointers, RTI_TRUE); - return key; + return key; } ConnextStaticRawData * ConnextStaticRawDataPluginSupport_create_key(void) { - return ConnextStaticRawDataPluginSupport_create_key_ex(RTI_TRUE); + return ConnextStaticRawDataPluginSupport_create_key_ex(RTI_TRUE); } void ConnextStaticRawDataPluginSupport_destroy_key_ex( - ConnextStaticRawDataKeyHolder *key,RTIBool deallocate_pointers) + ConnextStaticRawDataKeyHolder * key, RTIBool deallocate_pointers) { - ConnextStaticRawData_finalize_ex(key,deallocate_pointers); - - delete key; - key=NULL; + ConnextStaticRawData_finalize_ex(key, deallocate_pointers); + delete key; + key = NULL; } void ConnextStaticRawDataPluginSupport_destroy_key( - ConnextStaticRawDataKeyHolder *key) { - - ConnextStaticRawDataPluginSupport_destroy_key_ex(key,RTI_TRUE); - + ConnextStaticRawDataKeyHolder * key) +{ + ConnextStaticRawDataPluginSupport_destroy_key_ex(key, RTI_TRUE); } /* ---------------------------------------------------------------------------- @@ -240,122 +237,119 @@ Callback functions: PRESTypePluginParticipantData ConnextStaticRawDataPlugin_on_participant_attached( - void *registration_data, - const struct PRESTypePluginParticipantInfo *participant_info, - RTIBool top_level_registration, - void *container_plugin_context, - RTICdrTypeCode *type_code) + void * registration_data, + const struct PRESTypePluginParticipantInfo * participant_info, + RTIBool top_level_registration, + void * container_plugin_context, + RTICdrTypeCode * type_code) { - 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 */ - - return PRESTypePluginDefaultParticipantData_new(participant_info); + 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 */ + return PRESTypePluginDefaultParticipantData_new(participant_info); } void ConnextStaticRawDataPlugin_on_participant_detached( - PRESTypePluginParticipantData participant_data) + PRESTypePluginParticipantData participant_data) { - - PRESTypePluginDefaultParticipantData_delete(participant_data); + PRESTypePluginDefaultParticipantData_delete(participant_data); } PRESTypePluginEndpointData ConnextStaticRawDataPlugin_on_endpoint_attached( - PRESTypePluginParticipantData participant_data, - const struct PRESTypePluginEndpointInfo *endpoint_info, - RTIBool top_level_registration, - void *containerPluginContext) + PRESTypePluginParticipantData participant_data, + const struct PRESTypePluginEndpointInfo * endpoint_info, + RTIBool top_level_registration, + void * containerPluginContext) { - PRESTypePluginEndpointData epd = NULL; - - unsigned int serializedSampleMaxSize; - - unsigned int serializedKeyMaxSize; - - if (top_level_registration) {} /* To avoid warnings */ - if (containerPluginContext) {} /* To avoid warnings */ - - epd = PRESTypePluginDefaultEndpointData_new( - participant_data, + PRESTypePluginEndpointData epd = NULL; + + unsigned int serializedSampleMaxSize; + + unsigned int serializedKeyMaxSize; + + if (top_level_registration) {} /* To avoid warnings */ + if (containerPluginContext) {} /* To avoid warnings */ + + epd = PRESTypePluginDefaultEndpointData_new( + participant_data, + endpoint_info, + (PRESTypePluginDefaultEndpointDataCreateSampleFunction) + ConnextStaticRawDataPluginSupport_create_data, + (PRESTypePluginDefaultEndpointDataDestroySampleFunction) + ConnextStaticRawDataPluginSupport_destroy_data, + (PRESTypePluginDefaultEndpointDataCreateKeyFunction) + ConnextStaticRawDataPluginSupport_create_key, + (PRESTypePluginDefaultEndpointDataDestroyKeyFunction) + ConnextStaticRawDataPluginSupport_destroy_key); + + if (epd == NULL) { + return NULL; + } + serializedKeyMaxSize = ConnextStaticRawDataPlugin_get_serialized_key_max_size( + epd, RTI_FALSE, RTI_CDR_ENCAPSULATION_ID_CDR_BE, 0); + + if (!PRESTypePluginDefaultEndpointData_createMD5StreamWithInfo( + epd, endpoint_info, serializedKeyMaxSize)) + { + PRESTypePluginDefaultEndpointData_delete(epd); + return NULL; + } + + if (endpoint_info->endpointKind == PRES_TYPEPLUGIN_ENDPOINT_WRITER) { + serializedSampleMaxSize = ConnextStaticRawDataPlugin_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, - (PRESTypePluginDefaultEndpointDataCreateSampleFunction) - ConnextStaticRawDataPluginSupport_create_data, - (PRESTypePluginDefaultEndpointDataDestroySampleFunction) - ConnextStaticRawDataPluginSupport_destroy_data, - (PRESTypePluginDefaultEndpointDataCreateKeyFunction) - ConnextStaticRawDataPluginSupport_create_key , - (PRESTypePluginDefaultEndpointDataDestroyKeyFunction) - ConnextStaticRawDataPluginSupport_destroy_key); - - if (epd == NULL) { - return NULL; - } - serializedKeyMaxSize = ConnextStaticRawDataPlugin_get_serialized_key_max_size( - epd,RTI_FALSE,RTI_CDR_ENCAPSULATION_ID_CDR_BE,0); - - if(!PRESTypePluginDefaultEndpointData_createMD5StreamWithInfo( - epd,endpoint_info,serializedKeyMaxSize)) + (PRESTypePluginGetSerializedSampleMaxSizeFunction) + ConnextStaticRawDataPlugin_get_serialized_sample_max_size, epd, + (PRESTypePluginGetSerializedSampleSizeFunction) + ConnextStaticRawDataPlugin_get_serialized_sample_size, + epd) == RTI_FALSE) { - PRESTypePluginDefaultEndpointData_delete(epd); - return NULL; - } - - if (endpoint_info->endpointKind == PRES_TYPEPLUGIN_ENDPOINT_WRITER) { - serializedSampleMaxSize = ConnextStaticRawDataPlugin_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) - ConnextStaticRawDataPlugin_get_serialized_sample_max_size, epd, - (PRESTypePluginGetSerializedSampleSizeFunction) - ConnextStaticRawDataPlugin_get_serialized_sample_size, - epd) == RTI_FALSE) { - PRESTypePluginDefaultEndpointData_delete(epd); - return NULL; - } + PRESTypePluginDefaultEndpointData_delete(epd); + return NULL; } + } - return epd; + return epd; } void ConnextStaticRawDataPlugin_on_endpoint_detached( - PRESTypePluginEndpointData endpoint_data) + PRESTypePluginEndpointData endpoint_data) { - - PRESTypePluginDefaultEndpointData_delete(endpoint_data); + PRESTypePluginDefaultEndpointData_delete(endpoint_data); } void ConnextStaticRawDataPlugin_return_sample( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData *sample, - void *handle) + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData * sample, + void * handle) { + ConnextStaticRawData_finalize_optional_members(sample, RTI_TRUE); - ConnextStaticRawData_finalize_optional_members(sample, RTI_TRUE); - - PRESTypePluginDefaultEndpointData_returnSample( - endpoint_data, sample, handle); + PRESTypePluginDefaultEndpointData_returnSample( + endpoint_data, sample, handle); } RTIBool ConnextStaticRawDataPlugin_copy_sample( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData *dst, - const ConnextStaticRawData *src) + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData * dst, + const ConnextStaticRawData * src) { - if (endpoint_data) {} /* To avoid warnings */ - return ConnextStaticRawDataPluginSupport_copy_data(dst,src); + if (endpoint_data) {} /* To avoid warnings */ + return ConnextStaticRawDataPluginSupport_copy_data(dst, src); } /* ---------------------------------------------------------------------------- @@ -363,67 +357,68 @@ ConnextStaticRawDataPlugin_copy_sample( * ------------------------------------------------------------------------- */ unsigned int ConnextStaticRawDataPlugin_get_serialized_sample_max_size( - PRESTypePluginEndpointData endpoint_data, - RTIBool include_encapsulation, - RTIEncapsulationId encapsulation_id, - unsigned int current_alignment); + PRESTypePluginEndpointData endpoint_data, + RTIBool include_encapsulation, + RTIEncapsulationId encapsulation_id, + unsigned int current_alignment); RTIBool ConnextStaticRawDataPlugin_serialize( - PRESTypePluginEndpointData endpoint_data, - const ConnextStaticRawData *sample, - struct RTICdrStream *stream, - RTIBool serialize_encapsulation, - RTIEncapsulationId encapsulation_id, - RTIBool serialize_sample, - void *endpoint_plugin_qos) + PRESTypePluginEndpointData endpoint_data, + const ConnextStaticRawData * sample, + struct RTICdrStream * stream, + RTIBool serialize_encapsulation, + RTIEncapsulationId encapsulation_id, + RTIBool serialize_sample, + void * endpoint_plugin_qos) { - char * position = NULL; - RTIBool retval = RTI_TRUE; - - if (endpoint_data) {} /* To avoid warnings */ - if (endpoint_plugin_qos) {} /* To avoid warnings */ - - /* This plugin can only be used to publish the top-level DDS Topic-Type - * in which case serialize_encapsulation==TRUE. If that is not - * the case then it is an error. + char * position = NULL; + RTIBool retval = RTI_TRUE; + + if (endpoint_data) {} /* To avoid warnings */ + if (endpoint_plugin_qos) {} /* To avoid warnings */ + + /* This plugin can only be used to publish the top-level DDS Topic-Type + * in which case serialize_encapsulation==TRUE. If that is not + * the case then it is an error. + */ + if (!serialize_encapsulation) { + return RTI_FALSE; + } + + position = RTICdrStream_resetAlignment(stream); + + if (serialize_sample) { + /* The sample->serialized_data contains the serialized encapsulation followed by the serialized + * data, so we only need to copy that into + * the CDR stream. Not the key_hash, not the length of the data itself + * The SerializedType sample->serialized_data is always a contiguous buffer */ - if (!serialize_encapsulation) { - return RTI_FALSE; + DDS_Octet * buffer = DDS_OctetSeq_get_contiguous_bufferI(&sample->serialized_data); + if (buffer == NULL) { + return RTI_FALSE; } - position = RTICdrStream_resetAlignment(stream); + /* The encapsulation_id appears in the sample->serialized_data as octet[2] using big-endian + * byte order + */ + if (encapsulation_id != (buffer[0] * 256 + buffer[1]) ) { + return RTI_FALSE; + } - if(serialize_sample) { - /* The sample->serialized_data contains the serialized encapsulation followed by the serialized - * data, so we only need to copy that into - * the CDR stream. Not the key_hash, not the length of the data itself - * The SerializedType sample->serialized_data is always a contiguous buffer - */ - DDS_Octet *buffer = DDS_OctetSeq_get_contiguous_bufferI(&sample->serialized_data); - if ( buffer == NULL ) { - return RTI_FALSE; - } - - /* The encapsulation_id appears in the sample->serialized_data as octet[2] using big-endian - * byte order - */ - if ( encapsulation_id != (buffer[0] * 256 + buffer[1]) ) { - return RTI_FALSE; - } - - /* Use RTICdrStream_serializePrimitiveArray so that there is no additional length prepended */ - if (!RTICdrStream_serializePrimitiveArray( - stream, (void*)buffer, - DDS_OctetSeq_get_length(&sample->serialized_data), - RTI_CDR_OCTET_TYPE)) { - return RTI_FALSE; - } + /* Use RTICdrStream_serializePrimitiveArray so that there is no additional length prepended */ + if (!RTICdrStream_serializePrimitiveArray( + stream, (void *)buffer, // NOLINT + DDS_OctetSeq_get_length(&sample->serialized_data), + RTI_CDR_OCTET_TYPE)) + { + return RTI_FALSE; } + } - RTICdrStream_restoreAlignment(stream ,position); + RTICdrStream_restoreAlignment(stream, position); - return retval; + return retval; } /** @@ -442,413 +437,412 @@ ConnextStaticRawDataPlugin_serialize( RTICdrStream_getEncapsulationOptions() */ void -ConnextStaticRawDataPlugin_remove_padding_from_stream(struct RTICdrStream *stream) +ConnextStaticRawDataPlugin_remove_padding_from_stream(struct RTICdrStream * stream) { - /* See http://issues.omg.org/browse/DDSXTY12-10 */ - DDS_UnsignedShort padding_size_mask = 0x0003; - DDS_UnsignedShort padding_size; - int adjustedBufferLength; - - padding_size = RTICdrStream_getEncapsulationOptions(stream) & padding_size_mask; - adjustedBufferLength = RTICdrStream_getBufferLength(stream) - padding_size; - RTICdrStream_setBufferLength(stream, adjustedBufferLength); + // See http://issues.omg.org/browse/DDSXTY12-10 + DDS_UnsignedShort padding_size_mask = 0x0003; + DDS_UnsignedShort padding_size; + int adjustedBufferLength; + + padding_size = RTICdrStream_getEncapsulationOptions(stream) & padding_size_mask; + adjustedBufferLength = RTICdrStream_getBufferLength(stream) - padding_size; + RTICdrStream_setBufferLength(stream, adjustedBufferLength); } RTIBool ConnextStaticRawDataPlugin_deserialize_sample( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData *sample, - struct RTICdrStream *stream, - RTIBool deserialize_encapsulation, - RTIBool deserialize_sample, - void *endpoint_plugin_qos) + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData * sample, + struct RTICdrStream * stream, + RTIBool deserialize_encapsulation, + RTIBool deserialize_sample, + void * endpoint_plugin_qos) { - char * position = NULL; - RTIBool done = RTI_FALSE; - - if (endpoint_data) {} /* To avoid warnings */ - if (endpoint_plugin_qos) {} /* To avoid warnings */ - - /* This plugin can only be used to publish the top-level DDS Topic-Type - * in which case deserialize_encapsulation==TRUE. If that is not - * the case then it is an error. - */ - if (!deserialize_encapsulation) { - return RTI_FALSE; - } - - position = RTICdrStream_resetAlignment(stream); - - /* TODO. The call does not belong here. It should be pushed - * inside RTICdrStream_deserializeAndSetCdrEncapsulation + char * position = NULL; + RTIBool done = RTI_FALSE; + + if (endpoint_data) {} /* To avoid warnings */ + if (endpoint_plugin_qos) {} /* To avoid warnings */ + + /* This plugin can only be used to publish the top-level DDS Topic-Type + * in which case deserialize_encapsulation==TRUE. If that is not + * the case then it is an error. + */ + if (!deserialize_encapsulation) { + return RTI_FALSE; + } + + position = RTICdrStream_resetAlignment(stream); + + /* TODO. The call does not belong here. It should be pushed + * inside RTICdrStream_deserializeAndSetCdrEncapsulation + */ + ConnextStaticRawDataPlugin_remove_padding_from_stream(stream); + + if (deserialize_sample) { + /* Note that sample->key_hash was already set by SerializedTypePlugin_deserialize() + it is done there because SerializedTypePlugin_deserialize_sample does not + have access to the SampleInfo where that information is + */ + + /* We do not set the serialized_key on deserialization */ + DDS_OctetSeq_set_length(&sample->serialized_key, 0); + + /* We copy everything that remains in the CDR stream */ + int bytesLeftInStream = RTICdrStream_getRemainder(stream); + DDS_Octet * cdrBufferPtr = (DDS_Octet *) RTICdrStream_getCurrentPosition(stream); // NOLINT + if (cdrBufferPtr == NULL) { + goto fin; + } + + /* Do not call SerializedType_initialize_ex initialize here + because it would override the key_hash field + SerializedType_initialize_ex(sample, RTI_FALSE, RTI_FALSE); */ - ConnextStaticRawDataPlugin_remove_padding_from_stream(stream); - - if (deserialize_sample) { - /* Note that sample->key_hash was already set by SerializedTypePlugin_deserialize() - it is done there because SerializedTypePlugin_deserialize_sample does not - have access to the SampleInfo where that information is - */ - - /* We do not set the serialized_key on deserialization */ - DDS_OctetSeq_set_length(&sample->serialized_key, 0); - - /* We copy everything that remains in the CDR stream */ - int bytesLeftInStream = RTICdrStream_getRemainder(stream); - DDS_Octet *cdrBufferPtr = (DDS_Octet *) RTICdrStream_getCurrentPosition(stream); - if (cdrBufferPtr == NULL) { - goto fin; - } - - /* Do not call SerializedType_initialize_ex initialize here - because it would override the key_hash field - SerializedType_initialize_ex(sample, RTI_FALSE, RTI_FALSE); - */ - if (!DDS_OctetSeq_from_array(&sample->serialized_data, cdrBufferPtr, bytesLeftInStream) ) { - goto fin; - } - RTICdrStream_incrementCurrentPosition(stream, bytesLeftInStream); + if (!DDS_OctetSeq_from_array(&sample->serialized_data, cdrBufferPtr, bytesLeftInStream) ) { + goto fin; } + RTICdrStream_incrementCurrentPosition(stream, bytesLeftInStream); + } - done = RTI_TRUE; + done = RTI_TRUE; - fin: - if ( (done != RTI_TRUE) && - (RTICdrStream_getRemainder(stream) >= RTI_CDR_PARAMETER_HEADER_ALIGNMENT) ) { - return RTI_FALSE; - } +fin: + if ( (done != RTI_TRUE) && + (RTICdrStream_getRemainder(stream) >= RTI_CDR_PARAMETER_HEADER_ALIGNMENT) ) + { + return RTI_FALSE; + } - RTICdrStream_restoreAlignment(stream,position); + RTICdrStream_restoreAlignment(stream, position); - return RTI_TRUE; + return RTI_TRUE; } RTIBool ConnextStaticRawDataPlugin_serialize_to_cdr_buffer( - char * buffer, - unsigned int * length, - const ConnextStaticRawData *sample) + char * buffer, + unsigned int * length, + const ConnextStaticRawData * sample) { - struct RTICdrStream stream; - struct PRESTypePluginDefaultEndpointData epd; - RTIBool result; + struct RTICdrStream stream; + struct PRESTypePluginDefaultEndpointData epd; + RTIBool result; - if (length == NULL) { - return RTI_FALSE; - } + if (length == NULL) { + return RTI_FALSE; + } - epd._maxSizeSerializedSample = + epd._maxSizeSerializedSample = ConnextStaticRawDataPlugin_get_serialized_sample_max_size( - NULL, RTI_TRUE, RTICdrEncapsulation_getNativeCdrEncapsulationId(), 0); + NULL, RTI_TRUE, RTICdrEncapsulation_getNativeCdrEncapsulationId(), 0); - if (buffer == NULL) { - *length = - ConnextStaticRawDataPlugin_get_serialized_sample_size( - (PRESTypePluginEndpointData)&epd, - RTI_TRUE, - RTICdrEncapsulation_getNativeCdrEncapsulationId(), - 0, - sample); - - if (*length == 0) { - return RTI_FALSE; - } - - return RTI_TRUE; + if (buffer == NULL) { + *length = + ConnextStaticRawDataPlugin_get_serialized_sample_size( + (PRESTypePluginEndpointData) & epd, + RTI_TRUE, + RTICdrEncapsulation_getNativeCdrEncapsulationId(), + 0, + sample); + + if (*length == 0) { + return RTI_FALSE; } - RTICdrStream_init(&stream); - RTICdrStream_set(&stream, (char *)buffer, *length); + return RTI_TRUE; + } + + RTICdrStream_init(&stream); + RTICdrStream_set(&stream, (char *)buffer, *length); // NOLINT - result = ConnextStaticRawDataPlugin_serialize( - (PRESTypePluginEndpointData)&epd, sample, &stream, - RTI_TRUE, RTICdrEncapsulation_getNativeCdrEncapsulationId(), - RTI_TRUE, NULL); + result = ConnextStaticRawDataPlugin_serialize( + (PRESTypePluginEndpointData) & epd, sample, &stream, + RTI_TRUE, RTICdrEncapsulation_getNativeCdrEncapsulationId(), + RTI_TRUE, NULL); - *length = RTICdrStream_getCurrentPositionOffset(&stream); - return result; + *length = RTICdrStream_getCurrentPositionOffset(&stream); + return result; } RTIBool ConnextStaticRawDataPlugin_deserialize_from_cdr_buffer( - ConnextStaticRawData *sample, - const char * buffer, - unsigned int length) + ConnextStaticRawData * sample, + const char * buffer, + unsigned int length) { - struct RTICdrStream stream; + struct RTICdrStream stream; - RTICdrStream_init(&stream); - RTICdrStream_set(&stream, (char *)buffer, length); + RTICdrStream_init(&stream); + RTICdrStream_set(&stream, (char *)buffer, length); // NOLINT - ConnextStaticRawData_finalize_optional_members(sample, RTI_TRUE); - return ConnextStaticRawDataPlugin_deserialize_sample( - NULL, sample, - &stream, RTI_TRUE, RTI_TRUE, - NULL); + ConnextStaticRawData_finalize_optional_members(sample, RTI_TRUE); + return ConnextStaticRawDataPlugin_deserialize_sample( + NULL, sample, + &stream, RTI_TRUE, RTI_TRUE, + NULL); } DDS_ReturnCode_t ConnextStaticRawDataPlugin_data_to_string( - const ConnextStaticRawData *sample, - char *str, - DDS_UnsignedLong *str_size, - const struct DDS_PrintFormatProperty *property) + const ConnextStaticRawData * 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 (!ConnextStaticRawDataPlugin_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 (!ConnextStaticRawDataPlugin_serialize_to_cdr_buffer( - buffer, - &length, - sample)) { - RTIOsapiHeap_freeBuffer(buffer); - return DDS_RETCODE_ERROR; - } - - data = DDS_DynamicData_new( - ConnextStaticRawData_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; - } + 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 (!ConnextStaticRawDataPlugin_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 (!ConnextStaticRawDataPlugin_serialize_to_cdr_buffer( + buffer, + &length, + sample)) + { + RTIOsapiHeap_freeBuffer(buffer); + return DDS_RETCODE_ERROR; + } - retCode = DDS_PrintFormatProperty_to_print_format( - property, - &printFormat); - if (retCode != DDS_RETCODE_OK) { - RTIOsapiHeap_freeBuffer(buffer); - DDS_DynamicData_delete(data); - return retCode; - } + data = DDS_DynamicData_new( + ConnextStaticRawData_get_typecode(), + &DDS_DYNAMIC_DATA_PROPERTY_DEFAULT); + if (data == NULL) { + RTIOsapiHeap_freeBuffer(buffer); + return DDS_RETCODE_ERROR; + } - 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; - } + 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 DDS_RETCODE_OK; + return retCode; + } + + RTIOsapiHeap_freeBuffer(buffer); + DDS_DynamicData_delete(data); + return DDS_RETCODE_OK; } RTIBool ConnextStaticRawDataPlugin_deserialize( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData **sample, - RTIBool * drop_sample, - struct RTICdrStream *stream, - RTIBool deserialize_encapsulation, - RTIBool deserialize_sample, - void *endpoint_plugin_qos) + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData ** sample, + RTIBool * drop_sample, + struct RTICdrStream * stream, + RTIBool deserialize_encapsulation, + RTIBool deserialize_sample, + void * endpoint_plugin_qos) { - - RTIBool result; - const char *METHOD_NAME = "ConnextStaticRawDataPlugin_deserialize"; - if (drop_sample) {} /* To avoid warnings */ - - stream->_xTypesState.unassignable = RTI_FALSE; - result= ConnextStaticRawDataPlugin_deserialize_sample( - endpoint_data, (sample != NULL)?*sample:NULL, - stream, deserialize_encapsulation, deserialize_sample, - endpoint_plugin_qos); - if (result) { - if (stream->_xTypesState.unassignable) { - result = RTI_FALSE; - } - } - if (!result && stream->_xTypesState.unassignable ) { - - RTICdrLog_exception( - METHOD_NAME, - &RTI_CDR_LOG_UNASSIGNABLE_SAMPLE_OF_TYPE_s, - "ConnextStaticRawData"); - - } - - return result; + RTIBool result; + const char * METHOD_NAME = "ConnextStaticRawDataPlugin_deserialize"; + if (drop_sample) {} /* To avoid warnings */ + + stream->_xTypesState.unassignable = RTI_FALSE; + result = ConnextStaticRawDataPlugin_deserialize_sample( + endpoint_data, (sample != NULL) ? *sample : NULL, + stream, deserialize_encapsulation, deserialize_sample, + endpoint_plugin_qos); + if (result) { + if (stream->_xTypesState.unassignable) { + result = RTI_FALSE; + } + } + if (!result && stream->_xTypesState.unassignable) { + RTICdrLog_exception( + METHOD_NAME, + &RTI_CDR_LOG_UNASSIGNABLE_SAMPLE_OF_TYPE_s, + "ConnextStaticRawData"); + } + + return result; } RTIBool ConnextStaticRawDataPlugin_skip( - PRESTypePluginEndpointData endpoint_data, - struct RTICdrStream *stream, - RTIBool skip_encapsulation, - RTIBool skip_sample, - void *endpoint_plugin_qos) + PRESTypePluginEndpointData endpoint_data, + struct RTICdrStream * stream, + RTIBool skip_encapsulation, + RTIBool skip_sample, + void * endpoint_plugin_qos) { - char * position = NULL; - - RTIBool done = RTI_FALSE; + char * position = NULL; - if (endpoint_data) {} /* To avoid warnings */ - if (endpoint_plugin_qos) {} /* To avoid warnings */ + RTIBool done = RTI_FALSE; - if(skip_encapsulation) { - if (!RTICdrStream_skipEncapsulation(stream)) { - return RTI_FALSE; - } + if (endpoint_data) {} /* To avoid warnings */ + if (endpoint_plugin_qos) {} /* To avoid warnings */ - position = RTICdrStream_resetAlignment(stream); + if (skip_encapsulation) { + if (!RTICdrStream_skipEncapsulation(stream)) { + return RTI_FALSE; } - if (skip_sample) { - - if (!RTICdrStream_skipPrimitiveArray( - stream, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE)) { - goto fin; - } - { - RTICdrUnsignedLong sequence_length; - if (!RTICdrStream_skipPrimitiveSequence( - stream, - &sequence_length, - RTI_CDR_OCTET_TYPE)){ - goto fin; - } - } - { - RTICdrUnsignedLong sequence_length; - if (!RTICdrStream_skipPrimitiveSequence( - stream, - &sequence_length, - RTI_CDR_OCTET_TYPE)){ - goto fin; - } - } - } + position = RTICdrStream_resetAlignment(stream); + } - done = RTI_TRUE; - fin: - if (done != RTI_TRUE && - RTICdrStream_getRemainder(stream) >= - RTI_CDR_PARAMETER_HEADER_ALIGNMENT) { - return RTI_FALSE; + if (skip_sample) { + if (!RTICdrStream_skipPrimitiveArray( + stream, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE)) + { + goto fin; } - if(skip_encapsulation) { - RTICdrStream_restoreAlignment(stream,position); + { + RTICdrUnsignedLong sequence_length; + if (!RTICdrStream_skipPrimitiveSequence( + stream, + &sequence_length, + RTI_CDR_OCTET_TYPE)) + { + goto fin; + } } + { + RTICdrUnsignedLong sequence_length; + if (!RTICdrStream_skipPrimitiveSequence( + stream, + &sequence_length, + RTI_CDR_OCTET_TYPE)) + { + goto fin; + } + } + } - return RTI_TRUE; + done = RTI_TRUE; +fin: + if (done != RTI_TRUE && + RTICdrStream_getRemainder(stream) >= + RTI_CDR_PARAMETER_HEADER_ALIGNMENT) + { + return RTI_FALSE; + } + if (skip_encapsulation) { + RTICdrStream_restoreAlignment(stream, position); + } + + return RTI_TRUE; } unsigned int ConnextStaticRawDataPlugin_get_serialized_sample_max_size_ex( - PRESTypePluginEndpointData endpoint_data, - RTIBool * overflow, - RTIBool include_encapsulation, - RTIEncapsulationId encapsulation_id, - unsigned int current_alignment) + PRESTypePluginEndpointData endpoint_data, + RTIBool * overflow, + RTIBool include_encapsulation, + RTIEncapsulationId encapsulation_id, + unsigned int current_alignment) { + (void) endpoint_data; + (void) include_encapsulation; + (void) encapsulation_id; + (void) current_alignment; - if (endpoint_data) {} /* To avoid warnings */ - if (include_encapsulation) {} - if (encapsulation_id) {} - if (current_alignment) {} - - if (overflow != NULL) { - *overflow = RTI_TRUE; - } - - return RTI_CDR_MAX_SERIALIZED_SIZE; + if (overflow != NULL) { + *overflow = RTI_TRUE; + } + return RTI_CDR_MAX_SERIALIZED_SIZE; } unsigned int ConnextStaticRawDataPlugin_get_serialized_sample_max_size( - PRESTypePluginEndpointData endpoint_data, - RTIBool include_encapsulation, - RTIEncapsulationId encapsulation_id, - unsigned int current_alignment) + PRESTypePluginEndpointData endpoint_data, + RTIBool include_encapsulation, + RTIEncapsulationId encapsulation_id, + unsigned int current_alignment) { - unsigned int size; - RTIBool overflow = RTI_FALSE; + unsigned int size; + RTIBool overflow = RTI_FALSE; - size = ConnextStaticRawDataPlugin_get_serialized_sample_max_size_ex( - endpoint_data,&overflow,include_encapsulation,encapsulation_id,current_alignment); + size = ConnextStaticRawDataPlugin_get_serialized_sample_max_size_ex( + endpoint_data, &overflow, include_encapsulation, encapsulation_id, current_alignment); - if (overflow) { - size = RTI_CDR_MAX_SERIALIZED_SIZE; - } + if (overflow) { + size = RTI_CDR_MAX_SERIALIZED_SIZE; + } - return size; + return size; } unsigned int ConnextStaticRawDataPlugin_get_serialized_sample_min_size( - PRESTypePluginEndpointData endpoint_data, - RTIBool include_encapsulation, - RTIEncapsulationId encapsulation_id, - unsigned int current_alignment) + PRESTypePluginEndpointData endpoint_data, + RTIBool include_encapsulation, + RTIEncapsulationId encapsulation_id, + unsigned int current_alignment) { + unsigned int initial_alignment = current_alignment; - unsigned int initial_alignment = current_alignment; - - unsigned int encapsulation_size = current_alignment; - - if (endpoint_data) {} /* To avoid warnings */ + unsigned int encapsulation_size = current_alignment; - if (include_encapsulation) { + if (endpoint_data) {} /* To avoid warnings */ - if (!RTICdrEncapsulation_validEncapsulationId(encapsulation_id)) { - return 1; - } - RTICdrStream_getEncapsulationSize(encapsulation_size); - encapsulation_size -= current_alignment; - current_alignment = 0; - initial_alignment = 0; + if (include_encapsulation) { + if (!RTICdrEncapsulation_validEncapsulationId(encapsulation_id)) { + return 1; } + RTICdrStream_getEncapsulationSize(encapsulation_size); + encapsulation_size -= current_alignment; + current_alignment = 0; + initial_alignment = 0; + } - current_alignment +=RTICdrType_getPrimitiveArrayMaxSizeSerialized( - current_alignment, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE); - current_alignment += RTICdrType_getPrimitiveSequenceMaxSizeSerialized( - current_alignment,0, RTI_CDR_OCTET_TYPE); - current_alignment += RTICdrType_getPrimitiveSequenceMaxSizeSerialized( - current_alignment,0, RTI_CDR_OCTET_TYPE); + current_alignment += RTICdrType_getPrimitiveArrayMaxSizeSerialized( + current_alignment, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE); + current_alignment += RTICdrType_getPrimitiveSequenceMaxSizeSerialized( + current_alignment, 0, RTI_CDR_OCTET_TYPE); + current_alignment += RTICdrType_getPrimitiveSequenceMaxSizeSerialized( + current_alignment, 0, RTI_CDR_OCTET_TYPE); - if (include_encapsulation) { - current_alignment += encapsulation_size; - } - return current_alignment - initial_alignment; + if (include_encapsulation) { + current_alignment += encapsulation_size; + } + return current_alignment - initial_alignment; } /* Returns the size of the sample in its serialized form (in bytes). @@ -859,63 +853,61 @@ ConnextStaticRawDataPlugin_get_serialized_sample_min_size( */ unsigned int ConnextStaticRawDataPlugin_get_serialized_sample_size( - PRESTypePluginEndpointData endpoint_data, - RTIBool include_encapsulation, - RTIEncapsulationId encapsulation_id, - unsigned int current_alignment, - const ConnextStaticRawData * sample) + PRESTypePluginEndpointData endpoint_data, + RTIBool include_encapsulation, + RTIEncapsulationId encapsulation_id, + unsigned int current_alignment, + const ConnextStaticRawData * sample) { - - unsigned int initial_alignment = current_alignment; - - unsigned int encapsulation_size = current_alignment; - struct PRESTypePluginDefaultEndpointData epd; - - if (sample==NULL) { - return 0; - } - if (endpoint_data == NULL) { - endpoint_data = (PRESTypePluginEndpointData) &epd; - PRESTypePluginDefaultEndpointData_setBaseAlignment( - endpoint_data, - current_alignment); - } - - if (include_encapsulation) { - - if (!RTICdrEncapsulation_validEncapsulationId(encapsulation_id)) { - return 1; - } - RTICdrStream_getEncapsulationSize(encapsulation_size); - encapsulation_size -= current_alignment; - current_alignment = 0; - initial_alignment = 0; - PRESTypePluginDefaultEndpointData_setBaseAlignment( - endpoint_data, - current_alignment); - } - - current_alignment += RTICdrType_getPrimitiveArrayMaxSizeSerialized( - PRESTypePluginDefaultEndpointData_getAlignment( - endpoint_data, current_alignment), - ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE); - - current_alignment += RTICdrType_getPrimitiveSequenceSerializedSize( - PRESTypePluginDefaultEndpointData_getAlignment( - endpoint_data, current_alignment), - DDS_OctetSeq_get_length(&sample->serialized_key), - RTI_CDR_OCTET_TYPE); - - current_alignment += RTICdrType_getPrimitiveSequenceSerializedSize( - PRESTypePluginDefaultEndpointData_getAlignment( - endpoint_data, current_alignment), - DDS_OctetSeq_get_length(&sample->serialized_data), - RTI_CDR_OCTET_TYPE); - - if (include_encapsulation) { - current_alignment += encapsulation_size; - } - return current_alignment - initial_alignment; + unsigned int initial_alignment = current_alignment; + + unsigned int encapsulation_size = current_alignment; + struct PRESTypePluginDefaultEndpointData epd; + + if (sample == NULL) { + return 0; + } + if (endpoint_data == NULL) { + endpoint_data = (PRESTypePluginEndpointData) & epd; + PRESTypePluginDefaultEndpointData_setBaseAlignment( + endpoint_data, + current_alignment); + } + + if (include_encapsulation) { + if (!RTICdrEncapsulation_validEncapsulationId(encapsulation_id)) { + return 1; + } + RTICdrStream_getEncapsulationSize(encapsulation_size); + encapsulation_size -= current_alignment; + current_alignment = 0; + initial_alignment = 0; + PRESTypePluginDefaultEndpointData_setBaseAlignment( + endpoint_data, + current_alignment); + } + + current_alignment += RTICdrType_getPrimitiveArrayMaxSizeSerialized( + PRESTypePluginDefaultEndpointData_getAlignment( + endpoint_data, current_alignment), + ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE); + + current_alignment += RTICdrType_getPrimitiveSequenceSerializedSize( + PRESTypePluginDefaultEndpointData_getAlignment( + endpoint_data, current_alignment), + DDS_OctetSeq_get_length(&sample->serialized_key), + RTI_CDR_OCTET_TYPE); + + current_alignment += RTICdrType_getPrimitiveSequenceSerializedSize( + PRESTypePluginDefaultEndpointData_getAlignment( + endpoint_data, current_alignment), + DDS_OctetSeq_get_length(&sample->serialized_data), + RTI_CDR_OCTET_TYPE); + + if (include_encapsulation) { + current_alignment += encapsulation_size; + } + return current_alignment - initial_alignment; } /* -------------------------------------------------------------------------------------- @@ -925,299 +917,331 @@ Key Management functions: PRESTypePluginKeyKind ConnextStaticRawDataPlugin_get_key_kind(void) { - return PRES_TYPEPLUGIN_NO_KEY; + return PRES_TYPEPLUGIN_NO_KEY; } RTIBool ConnextStaticRawDataPlugin_serialize_key( - PRESTypePluginEndpointData endpoint_data, - const ConnextStaticRawData *sample, - struct RTICdrStream *stream, - RTIBool serialize_encapsulation, - RTIEncapsulationId encapsulation_id, - RTIBool serialize_key, - void *endpoint_plugin_qos) + PRESTypePluginEndpointData endpoint_data, + const ConnextStaticRawData * sample, + struct RTICdrStream * stream, + RTIBool serialize_encapsulation, + RTIEncapsulationId encapsulation_id, + RTIBool serialize_key, + void * endpoint_plugin_qos) { - char * position = NULL; + char * position = NULL; - if (endpoint_data) {} /* To avoid warnings */ - if (endpoint_plugin_qos) {} /* To avoid warnings */ + if (endpoint_data) {} /* To avoid warnings */ + if (endpoint_plugin_qos) {} /* To avoid warnings */ - if(serialize_encapsulation) { - if (!RTICdrStream_serializeAndSetCdrEncapsulation(stream , encapsulation_id)) { - return RTI_FALSE; - } - - position = RTICdrStream_resetAlignment(stream); + if (serialize_encapsulation) { + if (!RTICdrStream_serializeAndSetCdrEncapsulation(stream, encapsulation_id)) { + return RTI_FALSE; } - if(serialize_key) { - - if (!RTICdrStream_serializePrimitiveArray( - stream, (void*) sample->key_hash, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE)) { - return RTI_FALSE; - } + position = RTICdrStream_resetAlignment(stream); + } + if (serialize_key) { + if (!RTICdrStream_serializePrimitiveArray( + stream, (void *) sample->key_hash, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE)) // NOLINT + { + return RTI_FALSE; } + } - if(serialize_encapsulation) { - RTICdrStream_restoreAlignment(stream,position); - } + if (serialize_encapsulation) { + RTICdrStream_restoreAlignment(stream, position); + } - return RTI_TRUE; + return RTI_TRUE; } RTIBool ConnextStaticRawDataPlugin_deserialize_key_sample( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData *sample, - struct RTICdrStream *stream, - RTIBool deserialize_encapsulation, - RTIBool deserialize_key, - void *endpoint_plugin_qos) + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData * sample, + struct RTICdrStream * stream, + RTIBool deserialize_encapsulation, + RTIBool deserialize_key, + void * endpoint_plugin_qos) { - try { - - char * position = NULL; - - if (endpoint_data) {} /* To avoid warnings */ - if (endpoint_plugin_qos) {} /* To avoid warnings */ - - if(deserialize_encapsulation) { - - if (!RTICdrStream_deserializeAndSetCdrEncapsulation(stream)) { - return RTI_FALSE; - } - - position = RTICdrStream_resetAlignment(stream); - } - if (deserialize_key) { - - if (!RTICdrStream_deserializePrimitiveArray( - stream, (void*) sample->key_hash, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE)) { - return RTI_FALSE; - } - - } + try { + char * position = NULL; - if(deserialize_encapsulation) { - RTICdrStream_restoreAlignment(stream,position); - } + if (endpoint_data) {} /* To avoid warnings */ + if (endpoint_plugin_qos) {} /* To avoid warnings */ - return RTI_TRUE; + if (deserialize_encapsulation) { + if (!RTICdrStream_deserializeAndSetCdrEncapsulation(stream)) { + return RTI_FALSE; + } - } catch (std::bad_alloc&) { + position = RTICdrStream_resetAlignment(stream); + } + if (deserialize_key) { + if (!RTICdrStream_deserializePrimitiveArray( + stream, (void *) sample->key_hash, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE)) // NOLINT + { return RTI_FALSE; + } } -} -RTIBool ConnextStaticRawDataPlugin_deserialize_key( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData **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= ConnextStaticRawDataPlugin_deserialize_key_sample( - endpoint_data, (sample != NULL)?*sample:NULL, stream, - deserialize_encapsulation, deserialize_key, endpoint_plugin_qos); - if (result) { - if (stream->_xTypesState.unassignable) { - result = RTI_FALSE; - } + if (deserialize_encapsulation) { + RTICdrStream_restoreAlignment(stream, position); } - return result; + return RTI_TRUE; + } catch (std::bad_alloc &) { + return RTI_FALSE; + } +} +RTIBool ConnextStaticRawDataPlugin_deserialize_key( + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData ** 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 = ConnextStaticRawDataPlugin_deserialize_key_sample( + 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 ConnextStaticRawDataPlugin_get_serialized_key_max_size_ex( - PRESTypePluginEndpointData endpoint_data, - RTIBool * overflow, - RTIBool include_encapsulation, - RTIEncapsulationId encapsulation_id, - unsigned int current_alignment) + PRESTypePluginEndpointData endpoint_data, + RTIBool * overflow, + RTIBool include_encapsulation, + RTIEncapsulationId encapsulation_id, + unsigned int current_alignment) { + unsigned int initial_alignment = current_alignment; - unsigned int initial_alignment = current_alignment; + unsigned int encapsulation_size = current_alignment; - unsigned int encapsulation_size = current_alignment; + if (endpoint_data) {} /* To avoid warnings */ + if (overflow) {} /* To avoid warnings */ - if (endpoint_data) {} /* To avoid warnings */ - if (overflow) {} /* To avoid warnings */ - - if (include_encapsulation) { - - if (!RTICdrEncapsulation_validEncapsulationId(encapsulation_id)) { - return 1; - } - RTICdrStream_getEncapsulationSize(encapsulation_size); - encapsulation_size -= current_alignment; - current_alignment = 0; - initial_alignment = 0; + if (include_encapsulation) { + if (!RTICdrEncapsulation_validEncapsulationId(encapsulation_id)) { + return 1; } + RTICdrStream_getEncapsulationSize(encapsulation_size); + encapsulation_size -= current_alignment; + current_alignment = 0; + initial_alignment = 0; + } - current_alignment +=RTICdrType_getPrimitiveArrayMaxSizeSerialized( - current_alignment, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE); + current_alignment += RTICdrType_getPrimitiveArrayMaxSizeSerialized( + current_alignment, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE); - if (include_encapsulation) { - current_alignment += encapsulation_size; - } - return current_alignment - initial_alignment; + if (include_encapsulation) { + current_alignment += encapsulation_size; + } + return current_alignment - initial_alignment; } unsigned int ConnextStaticRawDataPlugin_get_serialized_key_max_size( - PRESTypePluginEndpointData endpoint_data, - RTIBool include_encapsulation, - RTIEncapsulationId encapsulation_id, - unsigned int current_alignment) + PRESTypePluginEndpointData endpoint_data, + RTIBool include_encapsulation, + RTIEncapsulationId encapsulation_id, + unsigned int current_alignment) { - unsigned int size; - RTIBool overflow = RTI_FALSE; + unsigned int size; + RTIBool overflow = RTI_FALSE; - size = ConnextStaticRawDataPlugin_get_serialized_key_max_size_ex( - endpoint_data,&overflow,include_encapsulation,encapsulation_id,current_alignment); + size = ConnextStaticRawDataPlugin_get_serialized_key_max_size_ex( + endpoint_data, &overflow, include_encapsulation, encapsulation_id, current_alignment); - if (overflow) { - size = RTI_CDR_MAX_SERIALIZED_SIZE; - } + if (overflow) { + size = RTI_CDR_MAX_SERIALIZED_SIZE; + } - return size; + return size; } RTIBool ConnextStaticRawDataPlugin_serialized_sample_to_key( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData *sample, - struct RTICdrStream *stream, - RTIBool deserialize_encapsulation, - RTIBool deserialize_key, - void *endpoint_plugin_qos) + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData * sample, + struct RTICdrStream * stream, + RTIBool deserialize_encapsulation, + RTIBool deserialize_key, + void * endpoint_plugin_qos) { - char * position = NULL; + char * position = NULL; - RTIBool done = RTI_FALSE; - RTIBool error = RTI_FALSE; + RTIBool done = RTI_FALSE; + RTIBool error = RTI_FALSE; - if (endpoint_data) {} /* To avoid warnings */ - if (endpoint_plugin_qos) {} /* To avoid warnings */ + if (endpoint_data) {} /* To avoid warnings */ + if (endpoint_plugin_qos) {} /* To avoid warnings */ - if (stream == NULL) { - error = RTI_TRUE; - goto fin; - } - if(deserialize_encapsulation) { - if (!RTICdrStream_deserializeAndSetCdrEncapsulation(stream)) { - return RTI_FALSE; - } - position = RTICdrStream_resetAlignment(stream); + if (stream == NULL) { + error = RTI_TRUE; + goto fin; + } + if (deserialize_encapsulation) { + if (!RTICdrStream_deserializeAndSetCdrEncapsulation(stream)) { + return RTI_FALSE; } + position = RTICdrStream_resetAlignment(stream); + } - if (deserialize_key) { - - if (!RTICdrStream_deserializePrimitiveArray( - stream, (void*) sample->key_hash, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE)) { - return RTI_FALSE; - } - - { - RTICdrUnsignedLong sequence_length; - if (!RTICdrStream_skipPrimitiveSequence( - stream, - &sequence_length, - RTI_CDR_OCTET_TYPE)){ - goto fin; - } - } - - { - RTICdrUnsignedLong sequence_length; - if (!RTICdrStream_skipPrimitiveSequence( - stream, - &sequence_length, - RTI_CDR_OCTET_TYPE)){ - goto fin; - } - } + if (deserialize_key) { + if (!RTICdrStream_deserializePrimitiveArray( + stream, (void *) sample->key_hash, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE)) // NOLINT + { + return RTI_FALSE; + } + { + RTICdrUnsignedLong sequence_length; + if (!RTICdrStream_skipPrimitiveSequence( + stream, + &sequence_length, + RTI_CDR_OCTET_TYPE)) + { + goto fin; + } } - done = RTI_TRUE; - fin: - if(!error) { - if (done != RTI_TRUE && - RTICdrStream_getRemainder(stream) >= - RTI_CDR_PARAMETER_HEADER_ALIGNMENT) { - return RTI_FALSE; - } - } else { - return RTI_FALSE; + { + RTICdrUnsignedLong sequence_length; + if (!RTICdrStream_skipPrimitiveSequence( + stream, + &sequence_length, + RTI_CDR_OCTET_TYPE)) + { + goto fin; + } } + } - if(deserialize_encapsulation) { - RTICdrStream_restoreAlignment(stream,position); + done = RTI_TRUE; +fin: + if (!error) { + if (done != RTI_TRUE && + RTICdrStream_getRemainder(stream) >= + RTI_CDR_PARAMETER_HEADER_ALIGNMENT) + { + return RTI_FALSE; } + } else { + return RTI_FALSE; + } - return RTI_TRUE; + if (deserialize_encapsulation) { + RTICdrStream_restoreAlignment(stream, position); + } + + return RTI_TRUE; } RTIBool ConnextStaticRawDataPlugin_instance_to_key( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawDataKeyHolder *dst, - const ConnextStaticRawData *src) + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawDataKeyHolder * dst, + const ConnextStaticRawData * src) { - - if (endpoint_data) {} /* To avoid warnings */ - - if (!RTICdrType_copyArray( - dst->key_hash ,src->key_hash,((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_SIZE)) { - return RTI_FALSE; - } - return RTI_TRUE; + if (endpoint_data) {} /* To avoid warnings */ + + if (!RTICdrType_copyArray( + dst->key_hash, src->key_hash, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_SIZE)) + { + return RTI_FALSE; + } + return RTI_TRUE; } RTIBool ConnextStaticRawDataPlugin_key_to_instance( - PRESTypePluginEndpointData endpoint_data, - ConnextStaticRawData *dst, const - ConnextStaticRawDataKeyHolder *src) + PRESTypePluginEndpointData endpoint_data, + ConnextStaticRawData * dst, const + ConnextStaticRawDataKeyHolder * src) { - - if (endpoint_data) {} /* To avoid warnings */ - if (!RTICdrType_copyArray( - dst->key_hash ,src->key_hash,((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_SIZE)) { - return RTI_FALSE; - } - return RTI_TRUE; + if (endpoint_data) {} /* To avoid warnings */ + if (!RTICdrType_copyArray( + dst->key_hash, src->key_hash, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_SIZE)) + { + return RTI_FALSE; + } + return RTI_TRUE; } RTIBool ConnextStaticRawDataPlugin_instance_to_keyhash( - PRESTypePluginEndpointData endpoint_data, - DDS_KeyHash_t *keyhash, - const ConnextStaticRawData *instance) + PRESTypePluginEndpointData endpoint_data, + DDS_KeyHash_t * keyhash, + const ConnextStaticRawData * instance) { - struct RTICdrStream * md5Stream = NULL; - struct RTICdrStreamState cdrState; - char * buffer = NULL; + struct RTICdrStream * md5Stream = NULL; + struct RTICdrStreamState cdrState; + char * buffer = NULL; - RTICdrStreamState_init(&cdrState); - md5Stream = PRESTypePluginDefaultEndpointData_getMD5Stream(endpoint_data); + RTICdrStreamState_init(&cdrState); + md5Stream = PRESTypePluginDefaultEndpointData_getMD5Stream(endpoint_data); - if (md5Stream == NULL) { - return RTI_FALSE; + if (md5Stream == NULL) { + return RTI_FALSE; + } + + RTICdrStream_resetPosition(md5Stream); + RTICdrStream_setDirtyBit(md5Stream, RTI_TRUE); + + if (!ConnextStaticRawDataPlugin_serialize_key( + endpoint_data, + instance, + md5Stream, + RTI_FALSE, + RTI_CDR_ENCAPSULATION_ID_CDR_BE, + RTI_TRUE, + NULL)) + { + int size; + + RTICdrStream_pushState(md5Stream, &cdrState, -1); + + size = (int)ConnextStaticRawDataPlugin_get_serialized_sample_size( // NOLINT + endpoint_data, + RTI_FALSE, + RTI_CDR_ENCAPSULATION_ID_CDR_BE, + 0, + instance); + + if (size <= RTICdrStream_getBufferLength(md5Stream)) { + RTICdrStream_popState(md5Stream, &cdrState); + return RTI_FALSE; } + RTIOsapiHeap_allocateBuffer(&buffer, size, 0); + + if (buffer == NULL) { + RTICdrStream_popState(md5Stream, &cdrState); + return RTI_FALSE; + } + + RTICdrStream_set(md5Stream, buffer, size); + RTIOsapiMemory_zero( + RTICdrStream_getBuffer(md5Stream), + RTICdrStream_getBufferLength(md5Stream)); RTICdrStream_resetPosition(md5Stream); RTICdrStream_setDirtyBit(md5Stream, RTI_TRUE); - if (!ConnextStaticRawDataPlugin_serialize_key( endpoint_data, instance, @@ -1227,140 +1251,106 @@ ConnextStaticRawDataPlugin_instance_to_keyhash( RTI_TRUE, NULL)) { - int size; - - RTICdrStream_pushState(md5Stream, &cdrState, -1); - - size = (int)ConnextStaticRawDataPlugin_get_serialized_sample_size( - endpoint_data, - RTI_FALSE, - RTI_CDR_ENCAPSULATION_ID_CDR_BE, - 0, - instance); - - if (size <= RTICdrStream_getBufferLength(md5Stream)) { - RTICdrStream_popState(md5Stream, &cdrState); - return RTI_FALSE; - } - - RTIOsapiHeap_allocateBuffer(&buffer,size,0); - - if (buffer == NULL) { - RTICdrStream_popState(md5Stream, &cdrState); - return RTI_FALSE; - } - - RTICdrStream_set(md5Stream, buffer, size); - RTIOsapiMemory_zero( - RTICdrStream_getBuffer(md5Stream), - RTICdrStream_getBufferLength(md5Stream)); - RTICdrStream_resetPosition(md5Stream); - RTICdrStream_setDirtyBit(md5Stream, RTI_TRUE); - if (!ConnextStaticRawDataPlugin_serialize_key( - endpoint_data, - instance, - md5Stream, - RTI_FALSE, - RTI_CDR_ENCAPSULATION_ID_CDR_BE, - RTI_TRUE, - NULL)) - { - RTICdrStream_popState(md5Stream, &cdrState); - RTIOsapiHeap_freeBuffer(buffer); - return RTI_FALSE; - } + RTICdrStream_popState(md5Stream, &cdrState); + RTIOsapiHeap_freeBuffer(buffer); + return RTI_FALSE; } + } - if (PRESTypePluginDefaultEndpointData_getMaxSizeSerializedKey(endpoint_data) > + if (PRESTypePluginDefaultEndpointData_getMaxSizeSerializedKey(endpoint_data) > (unsigned int)(MIG_RTPS_KEY_HASH_MAX_LENGTH) || - PRESTypePluginDefaultEndpointData_forceMD5KeyHash(endpoint_data)) { - RTICdrStream_computeMD5(md5Stream, keyhash->value); - } else { - RTIOsapiMemory_zero(keyhash->value,MIG_RTPS_KEY_HASH_MAX_LENGTH); - RTIOsapiMemory_copy( - keyhash->value, - RTICdrStream_getBuffer(md5Stream), - RTICdrStream_getCurrentPositionOffset(md5Stream)); - } - - keyhash->length = MIG_RTPS_KEY_HASH_MAX_LENGTH; - - if (buffer != NULL) { - RTICdrStream_popState(md5Stream, &cdrState); - RTIOsapiHeap_freeBuffer(buffer); - } + PRESTypePluginDefaultEndpointData_forceMD5KeyHash(endpoint_data)) + { + RTICdrStream_computeMD5(md5Stream, keyhash->value); + } else { + RTIOsapiMemory_zero(keyhash->value, MIG_RTPS_KEY_HASH_MAX_LENGTH); + RTIOsapiMemory_copy( + keyhash->value, + RTICdrStream_getBuffer(md5Stream), + RTICdrStream_getCurrentPositionOffset(md5Stream)); + } + + keyhash->length = MIG_RTPS_KEY_HASH_MAX_LENGTH; + + if (buffer != NULL) { + RTICdrStream_popState(md5Stream, &cdrState); + RTIOsapiHeap_freeBuffer(buffer); + } - return RTI_TRUE; + return RTI_TRUE; } RTIBool ConnextStaticRawDataPlugin_serialized_sample_to_keyhash( - PRESTypePluginEndpointData endpoint_data, - struct RTICdrStream *stream, - DDS_KeyHash_t *keyhash, - RTIBool deserialize_encapsulation, - void *endpoint_plugin_qos) + PRESTypePluginEndpointData endpoint_data, + struct RTICdrStream * stream, + DDS_KeyHash_t * keyhash, + RTIBool deserialize_encapsulation, + void * endpoint_plugin_qos) { - char * position = NULL; + char * position = NULL; - RTIBool done = RTI_FALSE; - RTIBool error = RTI_FALSE; - ConnextStaticRawData * sample=NULL; + RTIBool done = RTI_FALSE; + RTIBool error = RTI_FALSE; + ConnextStaticRawData * sample = NULL; - if (endpoint_plugin_qos) {} /* To avoid warnings */ - if (stream == NULL) { - error = RTI_TRUE; - goto fin; - } + if (endpoint_plugin_qos) {} /* To avoid warnings */ + if (stream == NULL) { + error = RTI_TRUE; + goto fin; + } - if(deserialize_encapsulation) { - if (!RTICdrStream_deserializeAndSetCdrEncapsulation(stream)) { - return RTI_FALSE; - } - - position = RTICdrStream_resetAlignment(stream); + if (deserialize_encapsulation) { + if (!RTICdrStream_deserializeAndSetCdrEncapsulation(stream)) { + return RTI_FALSE; } - sample = (ConnextStaticRawData *) + position = RTICdrStream_resetAlignment(stream); + } + + sample = (ConnextStaticRawData *) // NOLINT PRESTypePluginDefaultEndpointData_getTempSample(endpoint_data); - if (sample == NULL) { - return RTI_FALSE; - } + if (sample == NULL) { + return RTI_FALSE; + } - if (!RTICdrStream_deserializePrimitiveArray( - stream, (void*) sample->key_hash, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE)) { - return RTI_FALSE; - } + if (!RTICdrStream_deserializePrimitiveArray( + stream, (void *) sample->key_hash, ((KEY_HASH_LENGTH_16)), RTI_CDR_OCTET_TYPE)) // NOLINT + { + return RTI_FALSE; + } - done = RTI_TRUE; - fin: - if(!error) { - if (done != RTI_TRUE && - RTICdrStream_getRemainder(stream) >= - RTI_CDR_PARAMETER_HEADER_ALIGNMENT) { - return RTI_FALSE; - } - } else { - return RTI_FALSE; + done = RTI_TRUE; +fin: + if (!error) { + if (done != RTI_TRUE && + RTICdrStream_getRemainder(stream) >= + RTI_CDR_PARAMETER_HEADER_ALIGNMENT) + { + return RTI_FALSE; } + } else { + return RTI_FALSE; + } - if(deserialize_encapsulation) { - RTICdrStream_restoreAlignment(stream,position); - } + if (deserialize_encapsulation) { + RTICdrStream_restoreAlignment(stream, position); + } - if (!ConnextStaticRawDataPlugin_instance_to_keyhash( - endpoint_data, keyhash, sample)) { - return RTI_FALSE; - } + if (!ConnextStaticRawDataPlugin_instance_to_keyhash( + endpoint_data, keyhash, sample)) + { + return RTI_FALSE; + } - return RTI_TRUE; + return RTI_TRUE; } /* ------------------------------------------------------------------------ * Plug-in Installation Methods * ------------------------------------------------------------------------ */ -struct PRESTypePlugin *ConnextStaticRawDataPlugin_new(void) +struct PRESTypePlugin * ConnextStaticRawDataPlugin_new(void) { return NULL; } @@ -1368,129 +1358,129 @@ struct PRESTypePlugin *ConnextStaticRawDataPlugin_new(void) struct PRESTypePlugin * ConnextStaticRawDataPlugin_new_external(struct DDS_TypeCode * external_type_code) { - if (external_type_code == NULL) { - return NULL; - } + if (external_type_code == NULL) { + return NULL; + } - struct PRESTypePlugin *plugin = NULL; - const struct PRESTypePluginVersion PLUGIN_VERSION = + struct PRESTypePlugin * plugin = NULL; + const struct PRESTypePluginVersion PLUGIN_VERSION = PRES_TYPE_PLUGIN_VERSION_2_0; - RTIOsapiHeap_allocateStructure( - &plugin, struct PRESTypePlugin); + RTIOsapiHeap_allocateStructure( + &plugin, struct PRESTypePlugin); - if (plugin == NULL) { - return NULL; - } + if (plugin == NULL) { + return NULL; + } - plugin->version = PLUGIN_VERSION; + plugin->version = PLUGIN_VERSION; - /* set up parent's function pointers */ - plugin->onParticipantAttached = + /* set up parent's function pointers */ + plugin->onParticipantAttached = (PRESTypePluginOnParticipantAttachedCallback) ConnextStaticRawDataPlugin_on_participant_attached; - plugin->onParticipantDetached = + plugin->onParticipantDetached = (PRESTypePluginOnParticipantDetachedCallback) ConnextStaticRawDataPlugin_on_participant_detached; - plugin->onEndpointAttached = + plugin->onEndpointAttached = (PRESTypePluginOnEndpointAttachedCallback) ConnextStaticRawDataPlugin_on_endpoint_attached; - plugin->onEndpointDetached = + plugin->onEndpointDetached = (PRESTypePluginOnEndpointDetachedCallback) ConnextStaticRawDataPlugin_on_endpoint_detached; - plugin->copySampleFnc = + plugin->copySampleFnc = (PRESTypePluginCopySampleFunction) ConnextStaticRawDataPlugin_copy_sample; - plugin->createSampleFnc = + plugin->createSampleFnc = (PRESTypePluginCreateSampleFunction) ConnextStaticRawDataPlugin_create_sample; - plugin->destroySampleFnc = + plugin->destroySampleFnc = (PRESTypePluginDestroySampleFunction) ConnextStaticRawDataPlugin_destroy_sample; - plugin->serializeFnc = + plugin->serializeFnc = (PRESTypePluginSerializeFunction) ConnextStaticRawDataPlugin_serialize; - plugin->deserializeFnc = + plugin->deserializeFnc = (PRESTypePluginDeserializeFunction) ConnextStaticRawDataPlugin_deserialize; - plugin->getSerializedSampleMaxSizeFnc = + plugin->getSerializedSampleMaxSizeFnc = (PRESTypePluginGetSerializedSampleMaxSizeFunction) ConnextStaticRawDataPlugin_get_serialized_sample_max_size; - plugin->getSerializedSampleMinSizeFnc = + plugin->getSerializedSampleMinSizeFnc = (PRESTypePluginGetSerializedSampleMinSizeFunction) ConnextStaticRawDataPlugin_get_serialized_sample_min_size; - plugin->getSampleFnc = + plugin->getSampleFnc = (PRESTypePluginGetSampleFunction) ConnextStaticRawDataPlugin_get_sample; - plugin->returnSampleFnc = + plugin->returnSampleFnc = (PRESTypePluginReturnSampleFunction) ConnextStaticRawDataPlugin_return_sample; - //plugin->getKeyKindFnc = ConnextStaticRawDataPlugin_get_external_key_kind(external_type_code); - plugin->getKeyKindFnc = (PRESTypePluginGetKeyKindFunction) - ConnextStaticRawDataPlugin_get_key_kind; + // plugin->getKeyKindFnc = ConnextStaticRawDataPlugin_get_external_key_kind(external_type_code); + plugin->getKeyKindFnc = (PRESTypePluginGetKeyKindFunction) + ConnextStaticRawDataPlugin_get_key_kind; - plugin->getSerializedKeyMaxSizeFnc = + plugin->getSerializedKeyMaxSizeFnc = (PRESTypePluginGetSerializedKeyMaxSizeFunction) ConnextStaticRawDataPlugin_get_serialized_key_max_size; - plugin->serializeKeyFnc = + plugin->serializeKeyFnc = (PRESTypePluginSerializeKeyFunction) ConnextStaticRawDataPlugin_serialize_key; - plugin->deserializeKeyFnc = + plugin->deserializeKeyFnc = (PRESTypePluginDeserializeKeyFunction) ConnextStaticRawDataPlugin_deserialize_key; - plugin->deserializeKeySampleFnc = + plugin->deserializeKeySampleFnc = (PRESTypePluginDeserializeKeySampleFunction) ConnextStaticRawDataPlugin_deserialize_key_sample; - plugin-> instanceToKeyHashFnc = + plugin->instanceToKeyHashFnc = (PRESTypePluginInstanceToKeyHashFunction) ConnextStaticRawDataPlugin_instance_to_keyhash; - plugin->serializedSampleToKeyHashFnc = + plugin->serializedSampleToKeyHashFnc = (PRESTypePluginSerializedSampleToKeyHashFunction) ConnextStaticRawDataPlugin_serialized_sample_to_keyhash; - plugin->getKeyFnc = + plugin->getKeyFnc = (PRESTypePluginGetKeyFunction) ConnextStaticRawDataPlugin_get_key; - plugin->returnKeyFnc = + plugin->returnKeyFnc = (PRESTypePluginReturnKeyFunction) ConnextStaticRawDataPlugin_return_key; - plugin->instanceToKeyFnc = + plugin->instanceToKeyFnc = (PRESTypePluginInstanceToKeyFunction) ConnextStaticRawDataPlugin_instance_to_key; - plugin->keyToInstanceFnc = + plugin->keyToInstanceFnc = (PRESTypePluginKeyToInstanceFunction) ConnextStaticRawDataPlugin_key_to_instance; - plugin->serializedKeyToKeyHashFnc = NULL; /* Not supported yet */ - //plugin->typeCode = (struct RTICdrTypeCode *)ConnextStaticRawData_get_typecode(); - plugin->typeCode = (struct RTICdrTypeCode *)external_type_code; + plugin->serializedKeyToKeyHashFnc = NULL; /* Not supported yet */ + // plugin->typeCode = (struct RTICdrTypeCode *)ConnextStaticRawData_get_typecode(); + plugin->typeCode = (struct RTICdrTypeCode *)external_type_code; - plugin->languageKind = PRES_TYPEPLUGIN_CPP_LANG; + plugin->languageKind = PRES_TYPEPLUGIN_CPP_LANG; - /* Serialized buffer */ - plugin->getBuffer = + /* Serialized buffer */ + plugin->getBuffer = (PRESTypePluginGetBufferFunction) ConnextStaticRawDataPlugin_get_buffer; - plugin->returnBuffer = + plugin->returnBuffer = (PRESTypePluginReturnBufferFunction) ConnextStaticRawDataPlugin_return_buffer; - plugin->getSerializedSampleSizeFnc = + plugin->getSerializedSampleSizeFnc = (PRESTypePluginGetSerializedSampleSizeFunction) ConnextStaticRawDataPlugin_get_serialized_sample_size; - plugin->endpointTypeName = ConnextStaticRawDataTYPENAME; + plugin->endpointTypeName = ConnextStaticRawDataTYPENAME; - return plugin; + return plugin; } void -ConnextStaticRawDataPlugin_delete(struct PRESTypePlugin *plugin) +ConnextStaticRawDataPlugin_delete(struct PRESTypePlugin * plugin) { - RTIOsapiHeap_freeStructure(plugin); + RTIOsapiHeap_freeStructure(plugin); } #undef RTI_CDR_CURRENT_SUBMODULE diff --git a/rmw_connext_cpp/src/connext_static_raw_data_support.cpp b/rmw_connext_cpp/src/connext_static_raw_data_support.cpp index 35c1d585..056930f4 100644 --- a/rmw_connext_cpp/src/connext_static_raw_data_support.cpp +++ b/rmw_connext_cpp/src/connext_static_raw_data_support.cpp @@ -147,7 +147,7 @@ ConnextStaticRawDataSupport_register_external_type( } delete_data_type = RTI_TRUE; - presTypePlugin->_userBuffer = (PRESWord *)dds_data_type; + presTypePlugin->_userBuffer = (PRESWord *)dds_data_type; // NOLINT already_registered = participant->is_type_registered(type_name); retcode = participant->register_type(type_name, presTypePlugin, NULL, !already_registered); @@ -167,10 +167,9 @@ ConnextStaticRawDataSupport_register_external_type( ConnextStaticRawDataPlugin_delete(presTypePlugin); } if (delete_data_type) { - delete (ConnextStaticRawDataTypeSupport *)dds_data_type; + delete (ConnextStaticRawDataTypeSupport *)dds_data_type; // NOLINT dds_data_type = NULL; } return retcode; } -