From 2db28f7703f02b0871c3e0b2628b40a2145476d0 Mon Sep 17 00:00:00 2001 From: Emilio Cuesta Date: Fri, 6 Feb 2026 12:46:15 +0100 Subject: [PATCH] Refs #23567: Regenerate types with Fast DDS Gen 3.3.2 Signed-off-by: Emilio Cuesta --- fastdds_python/test/types/CMakeLists.txt | 23 +- fastdds_python/test/types/test_complete.cxx | 2 +- fastdds_python/test/types/test_complete.h | 2 +- fastdds_python/test/types/test_complete.i | 2 +- .../test/types/test_completeCdrAux.hpp | 2 +- .../test/types/test_completeCdrAux.ipp | 2 +- .../test/types/test_completePubSubTypes.cxx | 184 +-- .../test/types/test_completePubSubTypes.h | 17 +- .../test/types/test_completePubSubTypes.i | 2 +- fastdds_python/test/types/test_completev1.cxx | 2 +- fastdds_python/test/types/test_completev1.h | 2 +- .../test/types/test_included_modules.cxx | 2 +- .../test/types/test_included_modules.h | 2 +- .../test/types/test_included_modules.i | 2 +- .../types/test_included_modulesCdrAux.hpp | 2 +- .../types/test_included_modulesCdrAux.ipp | 2 +- .../test_included_modulesPubSubTypes.cxx | 362 +++--- .../types/test_included_modulesPubSubTypes.h | 147 ++- .../types/test_included_modulesPubSubTypes.i | 2 +- .../test/types/test_included_modulesv1.cxx | 2 +- .../test/types/test_included_modulesv1.h | 2 +- fastdds_python/test/types/test_modules.cxx | 2 +- fastdds_python/test/types/test_modules.h | 2 +- fastdds_python/test/types/test_modules.i | 2 +- .../test/types/test_modulesCdrAux.hpp | 2 +- .../test/types/test_modulesCdrAux.ipp | 2 +- .../test/types/test_modulesPubSubTypes.cxx | 1134 ++++++++--------- .../test/types/test_modulesPubSubTypes.h | 415 +++--- .../test/types/test_modulesPubSubTypes.i | 2 +- fastdds_python/test/types/test_modulesv1.cxx | 2 +- fastdds_python/test/types/test_modulesv1.h | 2 +- .../HelloWorldExample/CMakeLists.txt | 9 +- .../HelloWorldExample/HelloWorld.cxx | 2 +- .../HelloWorldExample/HelloWorld.h | 2 +- .../HelloWorldExample/HelloWorld.i | 2 +- .../HelloWorldExample/HelloWorldCdrAux.hpp | 2 +- .../HelloWorldExample/HelloWorldCdrAux.ipp | 2 +- .../HelloWorldPubSubTypes.cxx | 67 +- .../HelloWorldExample/HelloWorldPubSubTypes.h | 7 +- .../HelloWorldExample/HelloWorldPubSubTypes.i | 2 +- .../HelloWorldExample/HelloWorldv1.cxx | 2 +- .../HelloWorldExample/HelloWorldv1.h | 2 +- 42 files changed, 1139 insertions(+), 1290 deletions(-) diff --git a/fastdds_python/test/types/CMakeLists.txt b/fastdds_python/test/types/CMakeLists.txt index b718edb0..557c338a 100644 --- a/fastdds_python/test/types/CMakeLists.txt +++ b/fastdds_python/test/types/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.20) # SWIG: use standard target name. if(POLICY CMP0078) @@ -27,6 +27,13 @@ find_package(fastrtps REQUIRED) set(CMAKE_POSITION_INDEPENDENT_CODE ON) +if(NOT WIN32) + # Default values for shared library suffix in MacOS + if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") + endif() +endif() + #Create library for C++ types add_library(${PROJECT_NAME} SHARED test_included_modules.cxx @@ -135,6 +142,13 @@ find_package(fastrtps REQUIRED) set(CMAKE_POSITION_INDEPENDENT_CODE ON) +if(NOT WIN32) + # Default values for shared library suffix in MacOS + if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") + endif() +endif() + #Create library for C++ types add_library(${PROJECT_NAME} SHARED test_modules.cxx @@ -243,6 +257,13 @@ find_package(fastrtps REQUIRED) set(CMAKE_POSITION_INDEPENDENT_CODE ON) +if(NOT WIN32) + # Default values for shared library suffix in MacOS + if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") + endif() +endif() + #Create library for C++ types add_library(${PROJECT_NAME} SHARED test_complete.cxx diff --git a/fastdds_python/test/types/test_complete.cxx b/fastdds_python/test/types/test_complete.cxx index f930ea78..97c93510 100644 --- a/fastdds_python/test/types/test_complete.cxx +++ b/fastdds_python/test/types/test_complete.cxx @@ -16,7 +16,7 @@ * @file test_complete.cpp * This source file contains the implementation of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifdef _WIN32 diff --git a/fastdds_python/test/types/test_complete.h b/fastdds_python/test/types/test_complete.h index 7a0b8a52..368f107f 100644 --- a/fastdds_python/test/types/test_complete.h +++ b/fastdds_python/test/types/test_complete.h @@ -16,7 +16,7 @@ * @file test_complete.h * This header file contains the declaration of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #include diff --git a/fastdds_python/test/types/test_complete.i b/fastdds_python/test/types/test_complete.i index 629d3567..861631dd 100644 --- a/fastdds_python/test/types/test_complete.i +++ b/fastdds_python/test/types/test_complete.i @@ -16,7 +16,7 @@ * @file test_complete.i * This header file contains the SWIG interface of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ %module test_complete diff --git a/fastdds_python/test/types/test_completeCdrAux.hpp b/fastdds_python/test/types/test_completeCdrAux.hpp index 25dd9394..3441e139 100644 --- a/fastdds_python/test/types/test_completeCdrAux.hpp +++ b/fastdds_python/test/types/test_completeCdrAux.hpp @@ -16,7 +16,7 @@ * @file test_completeCdrAux.hpp * This source file contains some definitions of CDR related functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifndef _FAST_DDS_GENERATED_TEST_COMPLETECDRAUX_HPP_ diff --git a/fastdds_python/test/types/test_completeCdrAux.ipp b/fastdds_python/test/types/test_completeCdrAux.ipp index 213ea1e8..f1da6c2f 100644 --- a/fastdds_python/test/types/test_completeCdrAux.ipp +++ b/fastdds_python/test/types/test_completeCdrAux.ipp @@ -16,7 +16,7 @@ * @file test_completeCdrAux.ipp * This source file contains some declarations of CDR related functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifndef _FAST_DDS_GENERATED_TEST_COMPLETECDRAUX_IPP_ diff --git a/fastdds_python/test/types/test_completePubSubTypes.cxx b/fastdds_python/test/types/test_completePubSubTypes.cxx index 0a558f44..1a2bd439 100644 --- a/fastdds_python/test/types/test_completePubSubTypes.cxx +++ b/fastdds_python/test/types/test_completePubSubTypes.cxx @@ -16,10 +16,13 @@ * @file test_completePubSubTypes.cpp * This header file contains the implementation of the serialization functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ +#include +#include + #include #include "test_completePubSubTypes.h" @@ -43,17 +46,10 @@ StructTypePubSubType::StructTypePubSubType() type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; - uint32_t keyLength = StructType_max_key_cdr_typesize > 16 ? StructType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); } StructTypePubSubType::~StructTypePubSubType() { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } } bool StructTypePubSubType::serialize( @@ -61,7 +57,8 @@ bool StructTypePubSubType::serialize( SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - StructType* p_type = static_cast(data); + StructType* p_type = + static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -84,7 +81,7 @@ bool StructTypePubSubType::serialize( // Serialize the object. ser << *p_type; #if FASTCDR_VERSION_MAJOR > 1 - ser.set_dds_cdr_options({0,0}); + ser.set_dds_cdr_options({0, 0}); #else ser.setDDSCdrOptions(0); #endif // FASTCDR_VERSION_MAJOR > 1 @@ -110,7 +107,8 @@ bool StructTypePubSubType::deserialize( try { // Convert DATA to pointer of your type - StructType* p_type = static_cast(data); + StructType* p_type = + static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); @@ -182,46 +180,11 @@ bool StructTypePubSubType::getKey( InstanceHandle_t* handle, bool force_md5) { - if (!m_isGetKeyDefined) - { - return false; - } - - StructType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - StructType_max_key_cdr_typesize); + static_cast(data); + static_cast(handle); + static_cast(force_md5); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || StructType_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; + return false; } @@ -232,6 +195,7 @@ bool StructTypePubSubType::getKey( + CompleteTestTypePubSubType::CompleteTestTypePubSubType() { setName("CompleteTestType"); @@ -244,17 +208,10 @@ CompleteTestTypePubSubType::CompleteTestTypePubSubType() type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; - uint32_t keyLength = CompleteTestType_max_key_cdr_typesize > 16 ? CompleteTestType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); } CompleteTestTypePubSubType::~CompleteTestTypePubSubType() { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } } bool CompleteTestTypePubSubType::serialize( @@ -262,7 +219,8 @@ bool CompleteTestTypePubSubType::serialize( SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - CompleteTestType* p_type = static_cast(data); + CompleteTestType* p_type = + static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -285,7 +243,7 @@ bool CompleteTestTypePubSubType::serialize( // Serialize the object. ser << *p_type; #if FASTCDR_VERSION_MAJOR > 1 - ser.set_dds_cdr_options({0,0}); + ser.set_dds_cdr_options({0, 0}); #else ser.setDDSCdrOptions(0); #endif // FASTCDR_VERSION_MAJOR > 1 @@ -311,7 +269,8 @@ bool CompleteTestTypePubSubType::deserialize( try { // Convert DATA to pointer of your type - CompleteTestType* p_type = static_cast(data); + CompleteTestType* p_type = + static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); @@ -383,52 +342,18 @@ bool CompleteTestTypePubSubType::getKey( InstanceHandle_t* handle, bool force_md5) { - if (!m_isGetKeyDefined) - { - return false; - } - - CompleteTestType* p_type = static_cast(data); + static_cast(data); + static_cast(handle); + static_cast(force_md5); - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - CompleteTestType_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || CompleteTestType_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; + return false; } + KeyedCompleteTestTypePubSubType::KeyedCompleteTestTypePubSubType() { setName("KeyedCompleteTestType"); @@ -441,16 +366,15 @@ KeyedCompleteTestTypePubSubType::KeyedCompleteTestTypePubSubType() type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = true; - uint32_t keyLength = KeyedCompleteTestType_max_key_cdr_typesize > 16 ? KeyedCompleteTestType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + key_buffer_ = nullptr; + get_key_buffer_nts(); } KeyedCompleteTestTypePubSubType::~KeyedCompleteTestTypePubSubType() { - if (m_keyBuffer != nullptr) + if (key_buffer_ != nullptr) { - free(m_keyBuffer); + free(key_buffer_); } } @@ -459,7 +383,8 @@ bool KeyedCompleteTestTypePubSubType::serialize( SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - KeyedCompleteTestType* p_type = static_cast(data); + KeyedCompleteTestType* p_type = + static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -482,7 +407,7 @@ bool KeyedCompleteTestTypePubSubType::serialize( // Serialize the object. ser << *p_type; #if FASTCDR_VERSION_MAJOR > 1 - ser.set_dds_cdr_options({0,0}); + ser.set_dds_cdr_options({0, 0}); #else ser.setDDSCdrOptions(0); #endif // FASTCDR_VERSION_MAJOR > 1 @@ -508,7 +433,8 @@ bool KeyedCompleteTestTypePubSubType::deserialize( try { // Convert DATA to pointer of your type - KeyedCompleteTestType* p_type = static_cast(data); + KeyedCompleteTestType* p_type = + static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); @@ -580,19 +506,26 @@ bool KeyedCompleteTestTypePubSubType::getKey( InstanceHandle_t* handle, bool force_md5) { - if (!m_isGetKeyDefined) + std::lock_guard guard(compute_key_mtx_); + KeyedCompleteTestType* p_type = + static_cast(data); + + // Ensure the key buffer is reserved + unsigned char* key_buffer = get_key_buffer_nts(); + if (key_buffer == nullptr) { return false; } - KeyedCompleteTestType* p_type = static_cast(data); - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer), KeyedCompleteTestType_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser( + fastbuffer, + eprosima::fastcdr::Cdr::BIG_ENDIANNESS, + eprosima::fastcdr::CdrVersion::XCDRv1); #if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); #else @@ -600,25 +533,40 @@ bool KeyedCompleteTestTypePubSubType::getKey( #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || KeyedCompleteTestType_max_key_cdr_typesize > 16) { - m_md5.init(); + MD5 md5; + md5.init(); #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + md5.update(key_buffer, static_cast(ser.getSerializedDataLength())); #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); + md5.update(key_buffer, static_cast(ser.get_serialized_data_length())); #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); + md5.finalize(); for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_md5.digest[i]; + handle->value[i] = md5.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle->value[i] = m_keyBuffer[i]; + handle->value[i] = key_buffer[i]; } } return true; } +unsigned char* KeyedCompleteTestTypePubSubType::get_key_buffer_nts() +{ + // If already reserved, return + if (key_buffer_ != nullptr) + { + return key_buffer_; + } + + // Allocate the key buffer + uint32_t key_length = (std::max)(KeyedCompleteTestType_max_key_cdr_typesize, 16u); + key_buffer_ = reinterpret_cast(calloc(key_length, 1u)); + return key_buffer_; +} + diff --git a/fastdds_python/test/types/test_completePubSubTypes.h b/fastdds_python/test/types/test_completePubSubTypes.h index d77cf3d3..01d31ae8 100644 --- a/fastdds_python/test/types/test_completePubSubTypes.h +++ b/fastdds_python/test/types/test_completePubSubTypes.h @@ -16,13 +16,15 @@ * @file test_completePubSubTypes.h * This header file contains the declaration of the serialization functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifndef _FAST_DDS_GENERATED_TEST_COMPLETE_PUBSUBTYPES_H_ #define _FAST_DDS_GENERATED_TEST_COMPLETE_PUBSUBTYPES_H_ +#include + #include #include #include @@ -124,9 +126,6 @@ class StructTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; - }; @@ -220,9 +219,6 @@ class CompleteTestTypePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; - }; @@ -312,9 +308,12 @@ class KeyedCompleteTestTypePubSubType : public eprosima::fastdds::dds::TopicData #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; +private: + + unsigned char* key_buffer_ = nullptr; + std::mutex compute_key_mtx_; + unsigned char* get_key_buffer_nts(); }; #endif // _FAST_DDS_GENERATED_TEST_COMPLETE_PUBSUBTYPES_H_ diff --git a/fastdds_python/test/types/test_completePubSubTypes.i b/fastdds_python/test/types/test_completePubSubTypes.i index 2c68f927..08e3c962 100644 --- a/fastdds_python/test/types/test_completePubSubTypes.i +++ b/fastdds_python/test/types/test_completePubSubTypes.i @@ -16,7 +16,7 @@ * @file test_completePubSubTypes.i * This header file contains the SWIG interface of the serialization functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ %import(module="fastdds") "fastdds/dds/topic/TopicDataType.hpp"; diff --git a/fastdds_python/test/types/test_completev1.cxx b/fastdds_python/test/types/test_completev1.cxx index 2bd17df1..e0637b49 100644 --- a/fastdds_python/test/types/test_completev1.cxx +++ b/fastdds_python/test/types/test_completev1.cxx @@ -16,7 +16,7 @@ * @file test_complete.cpp * This source file contains the implementation of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifdef _WIN32 diff --git a/fastdds_python/test/types/test_completev1.h b/fastdds_python/test/types/test_completev1.h index 7258f061..091a1399 100644 --- a/fastdds_python/test/types/test_completev1.h +++ b/fastdds_python/test/types/test_completev1.h @@ -16,7 +16,7 @@ * @file test_complete.h * This header file contains the declaration of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #include diff --git a/fastdds_python/test/types/test_included_modules.cxx b/fastdds_python/test/types/test_included_modules.cxx index d7e43b32..48459cc8 100644 --- a/fastdds_python/test/types/test_included_modules.cxx +++ b/fastdds_python/test/types/test_included_modules.cxx @@ -16,7 +16,7 @@ * @file test_included_modules.cpp * This source file contains the implementation of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifdef _WIN32 diff --git a/fastdds_python/test/types/test_included_modules.h b/fastdds_python/test/types/test_included_modules.h index d9254d64..8937f14b 100644 --- a/fastdds_python/test/types/test_included_modules.h +++ b/fastdds_python/test/types/test_included_modules.h @@ -16,7 +16,7 @@ * @file test_included_modules.h * This header file contains the declaration of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #include diff --git a/fastdds_python/test/types/test_included_modules.i b/fastdds_python/test/types/test_included_modules.i index ab3c0b66..552cf00d 100644 --- a/fastdds_python/test/types/test_included_modules.i +++ b/fastdds_python/test/types/test_included_modules.i @@ -16,7 +16,7 @@ * @file test_included_modules.i * This header file contains the SWIG interface of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ %module test_included_modules diff --git a/fastdds_python/test/types/test_included_modulesCdrAux.hpp b/fastdds_python/test/types/test_included_modulesCdrAux.hpp index 2724149f..36ef618b 100644 --- a/fastdds_python/test/types/test_included_modulesCdrAux.hpp +++ b/fastdds_python/test/types/test_included_modulesCdrAux.hpp @@ -16,7 +16,7 @@ * @file test_included_modulesCdrAux.hpp * This source file contains some definitions of CDR related functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifndef _FAST_DDS_GENERATED_EPROSIMA_TEST2_TEST_INCLUDED_MODULESCDRAUX_HPP_ diff --git a/fastdds_python/test/types/test_included_modulesCdrAux.ipp b/fastdds_python/test/types/test_included_modulesCdrAux.ipp index 7ea181f8..bf76f46b 100644 --- a/fastdds_python/test/types/test_included_modulesCdrAux.ipp +++ b/fastdds_python/test/types/test_included_modulesCdrAux.ipp @@ -16,7 +16,7 @@ * @file test_included_modulesCdrAux.ipp * This source file contains some declarations of CDR related functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifndef _FAST_DDS_GENERATED_EPROSIMA_TEST2_TEST_INCLUDED_MODULESCDRAUX_IPP_ diff --git a/fastdds_python/test/types/test_included_modulesPubSubTypes.cxx b/fastdds_python/test/types/test_included_modulesPubSubTypes.cxx index 0404d8c2..b34cfd8c 100644 --- a/fastdds_python/test/types/test_included_modulesPubSubTypes.cxx +++ b/fastdds_python/test/types/test_included_modulesPubSubTypes.cxx @@ -16,10 +16,13 @@ * @file test_included_modulesPubSubTypes.cpp * This header file contains the implementation of the serialization functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ +#include +#include + #include #include "test_included_modulesPubSubTypes.h" @@ -30,204 +33,165 @@ using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; namespace eprosima { - namespace test2 { - - - StructType2PubSubType::StructType2PubSubType() - { - setName("eprosima::test2::StructType2"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructType2::getMaxCdrSerializedSize()); - #else - eprosima_test2_StructType2_max_cdr_typesize; - #endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_test2_StructType2_max_key_cdr_typesize > 16 ? eprosima_test2_StructType2_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); - } - - StructType2PubSubType::~StructType2PubSubType() - { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } - } - - bool StructType2PubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) - { - StructType2* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); - #endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - #if FASTCDR_VERSION_MAJOR > 1 - ser.set_dds_cdr_options({0,0}); - #else - ser.setDDSCdrOptions(0); - #endif // FASTCDR_VERSION_MAJOR > 1 - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 - return true; - } - - bool StructType2PubSubType::deserialize( - SerializedPayload_t* payload, - void* data) - { - try - { - // Convert DATA to pointer of your type - StructType2* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; - } - - std::function StructType2PubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) - { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* StructType2PubSubType::createData() - { - return reinterpret_cast(new StructType2()); - } - - void StructType2PubSubType::deleteData( - void* data) - { - delete(reinterpret_cast(data)); - } - - bool StructType2PubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) - { - if (!m_isGetKeyDefined) - { - return false; - } - - StructType2* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - eprosima_test2_StructType2_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else - eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || eprosima_test2_StructType2_max_key_cdr_typesize > 16) - { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; - } - - - } //End of namespace test2 +namespace test2 { + + +StructType2PubSubType::StructType2PubSubType() +{ + setName("eprosima::test2::StructType2"); + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(StructType2::getMaxCdrSerializedSize()); +#else + eprosima_test2_StructType2_max_cdr_typesize; +#endif + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + m_typeSize = type_size + 4; /*encapsulation*/ + m_isGetKeyDefined = false; +} + +StructType2PubSubType::~StructType2PubSubType() +{ +} + +bool StructType2PubSubType::serialize( + void* data, + SerializedPayload_t* payload, + DataRepresentationId_t data_representation) +{ + StructType2* p_type = + static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; +#if FASTCDR_VERSION_MAJOR > 1 + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); +#endif // FASTCDR_VERSION_MAJOR > 1 + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; +#if FASTCDR_VERSION_MAJOR > 1 + ser.set_dds_cdr_options({0, 0}); +#else + ser.setDDSCdrOptions(0); +#endif // FASTCDR_VERSION_MAJOR > 1 + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length +#if FASTCDR_VERSION_MAJOR == 1 + payload->length = static_cast(ser.getSerializedDataLength()); +#else + payload->length = static_cast(ser.get_serialized_data_length()); +#endif // FASTCDR_VERSION_MAJOR == 1 + return true; +} + +bool StructType2PubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + StructType2* p_type = + static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN +#if FASTCDR_VERSION_MAJOR == 1 + , eprosima::fastcdr::Cdr::CdrType::DDS_CDR +#endif // FASTCDR_VERSION_MAJOR == 1 + ); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +std::function StructType2PubSubType::getSerializedSizeProvider( + void* data, + DataRepresentationId_t data_representation) +{ + return [data, data_representation]() -> uint32_t + { +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 + }; +} + +void* StructType2PubSubType::createData() +{ + return reinterpret_cast(new StructType2()); +} + +void StructType2PubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool StructType2PubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + static_cast(data); + static_cast(handle); + static_cast(force_md5); + + return false; +} + + + +} //End of namespace test2 } //End of namespace eprosima diff --git a/fastdds_python/test/types/test_included_modulesPubSubTypes.h b/fastdds_python/test/types/test_included_modulesPubSubTypes.h index a9962d68..c56c1d90 100644 --- a/fastdds_python/test/types/test_included_modulesPubSubTypes.h +++ b/fastdds_python/test/types/test_included_modulesPubSubTypes.h @@ -16,13 +16,15 @@ * @file test_included_modulesPubSubTypes.h * This header file contains the declaration of the serialization functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifndef _FAST_DDS_GENERATED_EPROSIMA_TEST2_TEST_INCLUDED_MODULES_PUBSUBTYPES_H_ #define _FAST_DDS_GENERATED_EPROSIMA_TEST2_TEST_INCLUDED_MODULES_PUBSUBTYPES_H_ +#include + #include #include #include @@ -37,102 +39,97 @@ Generated test_included_modules is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. #endif // GEN_API_VER -namespace eprosima -{ - namespace test2 - { +namespace eprosima { +namespace test2 { - /*! - * @brief This class represents the TopicDataType of the type StructType2 defined by the user in the IDL file. - * @ingroup test_included_modules - */ - class StructType2PubSubType : public eprosima::fastdds::dds::TopicDataType - { - public: - - typedef StructType2 type; +/*! + * @brief This class represents the TopicDataType of the type StructType2 defined by the user in the IDL file. + * @ingroup test_included_modules + */ +class StructType2PubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: - eProsima_user_DllExport StructType2PubSubType(); + typedef StructType2 type; - eProsima_user_DllExport ~StructType2PubSubType() override; + eProsima_user_DllExport StructType2PubSubType(); - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } + eProsima_user_DllExport ~StructType2PubSubType() override; - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + { + return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } + eProsima_user_DllExport bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data) override + { + return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport void deleteData( - void* data) override; + eProsima_user_DllExport void* createData() override; - #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } + eProsima_user_DllExport void deleteData( + void* data) override; - #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return false; + } - #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } - #endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + { + static_cast(data_representation); + return false; + } - #ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + static_cast(memory); + return false; + } - MD5 m_md5; - unsigned char* m_keyBuffer; +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - }; - } -} +}; +} // namespace test2 +} // namespace eprosima #endif // _FAST_DDS_GENERATED_EPROSIMA_TEST2_TEST_INCLUDED_MODULES_PUBSUBTYPES_H_ diff --git a/fastdds_python/test/types/test_included_modulesPubSubTypes.i b/fastdds_python/test/types/test_included_modulesPubSubTypes.i index 3c3a2891..b4ae8b80 100644 --- a/fastdds_python/test/types/test_included_modulesPubSubTypes.i +++ b/fastdds_python/test/types/test_included_modulesPubSubTypes.i @@ -16,7 +16,7 @@ * @file test_included_modulesPubSubTypes.i * This header file contains the SWIG interface of the serialization functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ %import(module="fastdds") "fastdds/dds/topic/TopicDataType.hpp"; diff --git a/fastdds_python/test/types/test_included_modulesv1.cxx b/fastdds_python/test/types/test_included_modulesv1.cxx index 58c44802..a862701f 100644 --- a/fastdds_python/test/types/test_included_modulesv1.cxx +++ b/fastdds_python/test/types/test_included_modulesv1.cxx @@ -16,7 +16,7 @@ * @file test_included_modules.cpp * This source file contains the implementation of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifdef _WIN32 diff --git a/fastdds_python/test/types/test_included_modulesv1.h b/fastdds_python/test/types/test_included_modulesv1.h index de5eb0f8..0eea6b43 100644 --- a/fastdds_python/test/types/test_included_modulesv1.h +++ b/fastdds_python/test/types/test_included_modulesv1.h @@ -16,7 +16,7 @@ * @file test_included_modules.h * This header file contains the declaration of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #include diff --git a/fastdds_python/test/types/test_modules.cxx b/fastdds_python/test/types/test_modules.cxx index 1f07eea0..ba842d69 100644 --- a/fastdds_python/test/types/test_modules.cxx +++ b/fastdds_python/test/types/test_modules.cxx @@ -16,7 +16,7 @@ * @file test_modules.cpp * This source file contains the implementation of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifdef _WIN32 diff --git a/fastdds_python/test/types/test_modules.h b/fastdds_python/test/types/test_modules.h index a74ede6d..b5bdf4e0 100644 --- a/fastdds_python/test/types/test_modules.h +++ b/fastdds_python/test/types/test_modules.h @@ -16,7 +16,7 @@ * @file test_modules.h * This header file contains the declaration of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #include diff --git a/fastdds_python/test/types/test_modules.i b/fastdds_python/test/types/test_modules.i index b26a9895..768c97c3 100644 --- a/fastdds_python/test/types/test_modules.i +++ b/fastdds_python/test/types/test_modules.i @@ -16,7 +16,7 @@ * @file test_modules.i * This header file contains the SWIG interface of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ %module test_modules diff --git a/fastdds_python/test/types/test_modulesCdrAux.hpp b/fastdds_python/test/types/test_modulesCdrAux.hpp index f591f9ec..7a5dc407 100644 --- a/fastdds_python/test/types/test_modulesCdrAux.hpp +++ b/fastdds_python/test/types/test_modulesCdrAux.hpp @@ -16,7 +16,7 @@ * @file test_modulesCdrAux.hpp * This source file contains some definitions of CDR related functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifndef _FAST_DDS_GENERATED_EPROSIMA_TEST_TEST_MODULESCDRAUX_HPP_ diff --git a/fastdds_python/test/types/test_modulesCdrAux.ipp b/fastdds_python/test/types/test_modulesCdrAux.ipp index 1ae1d7f7..08a7b1e6 100644 --- a/fastdds_python/test/types/test_modulesCdrAux.ipp +++ b/fastdds_python/test/types/test_modulesCdrAux.ipp @@ -16,7 +16,7 @@ * @file test_modulesCdrAux.ipp * This source file contains some declarations of CDR related functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifndef _FAST_DDS_GENERATED_EPROSIMA_TEST_TEST_MODULESCDRAUX_IPP_ diff --git a/fastdds_python/test/types/test_modulesPubSubTypes.cxx b/fastdds_python/test/types/test_modulesPubSubTypes.cxx index de1aecdf..bfbd0dad 100644 --- a/fastdds_python/test/types/test_modulesPubSubTypes.cxx +++ b/fastdds_python/test/types/test_modulesPubSubTypes.cxx @@ -16,10 +16,13 @@ * @file test_modulesPubSubTypes.cpp * This header file contains the implementation of the serialization functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ +#include +#include + #include #include "test_modulesPubSubTypes.h" @@ -30,602 +33,547 @@ using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; namespace eprosima { - namespace test { - - - StructTypePubSubType::StructTypePubSubType() - { - setName("eprosima::test::StructType"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(StructType::getMaxCdrSerializedSize()); - #else - eprosima_test_StructType_max_cdr_typesize; - #endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_test_StructType_max_key_cdr_typesize > 16 ? eprosima_test_StructType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); - } - - StructTypePubSubType::~StructTypePubSubType() - { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } - } - - bool StructTypePubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) - { - StructType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); - #endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - #if FASTCDR_VERSION_MAJOR > 1 - ser.set_dds_cdr_options({0,0}); - #else - ser.setDDSCdrOptions(0); - #endif // FASTCDR_VERSION_MAJOR > 1 - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 - return true; - } - - bool StructTypePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) - { - try - { - // Convert DATA to pointer of your type - StructType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; - } - - std::function StructTypePubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) - { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* StructTypePubSubType::createData() - { - return reinterpret_cast(new StructType()); - } - - void StructTypePubSubType::deleteData( - void* data) - { - delete(reinterpret_cast(data)); - } - - bool StructTypePubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) - { - if (!m_isGetKeyDefined) - { - return false; - } - - StructType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - eprosima_test_StructType_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else - eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || eprosima_test_StructType_max_key_cdr_typesize > 16) - { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; - } - - - - - - - - - - CompleteTestTypePubSubType::CompleteTestTypePubSubType() - { - setName("eprosima::test::CompleteTestType"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(CompleteTestType::getMaxCdrSerializedSize()); - #else - eprosima_test_CompleteTestType_max_cdr_typesize; - #endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_test_CompleteTestType_max_key_cdr_typesize > 16 ? eprosima_test_CompleteTestType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); - } - - CompleteTestTypePubSubType::~CompleteTestTypePubSubType() - { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } - } - - bool CompleteTestTypePubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) - { - CompleteTestType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); - #endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - #if FASTCDR_VERSION_MAJOR > 1 - ser.set_dds_cdr_options({0,0}); - #else - ser.setDDSCdrOptions(0); - #endif // FASTCDR_VERSION_MAJOR > 1 - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 - return true; - } - - bool CompleteTestTypePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) - { - try - { - // Convert DATA to pointer of your type - CompleteTestType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; - } - - std::function CompleteTestTypePubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) - { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* CompleteTestTypePubSubType::createData() - { - return reinterpret_cast(new CompleteTestType()); - } - - void CompleteTestTypePubSubType::deleteData( - void* data) - { - delete(reinterpret_cast(data)); - } - - bool CompleteTestTypePubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) - { - if (!m_isGetKeyDefined) - { - return false; - } - - CompleteTestType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - eprosima_test_CompleteTestType_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else - eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || eprosima_test_CompleteTestType_max_key_cdr_typesize > 16) - { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; - } - - - - - - KeyedCompleteTestTypePubSubType::KeyedCompleteTestTypePubSubType() +namespace test { + + +StructTypePubSubType::StructTypePubSubType() +{ + setName("eprosima::test::StructType"); + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(StructType::getMaxCdrSerializedSize()); +#else + eprosima_test_StructType_max_cdr_typesize; +#endif + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + m_typeSize = type_size + 4; /*encapsulation*/ + m_isGetKeyDefined = false; +} + +StructTypePubSubType::~StructTypePubSubType() +{ +} + +bool StructTypePubSubType::serialize( + void* data, + SerializedPayload_t* payload, + DataRepresentationId_t data_representation) +{ + StructType* p_type = + static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; +#if FASTCDR_VERSION_MAJOR > 1 + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); +#endif // FASTCDR_VERSION_MAJOR > 1 + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; +#if FASTCDR_VERSION_MAJOR > 1 + ser.set_dds_cdr_options({0, 0}); +#else + ser.setDDSCdrOptions(0); +#endif // FASTCDR_VERSION_MAJOR > 1 + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length +#if FASTCDR_VERSION_MAJOR == 1 + payload->length = static_cast(ser.getSerializedDataLength()); +#else + payload->length = static_cast(ser.get_serialized_data_length()); +#endif // FASTCDR_VERSION_MAJOR == 1 + return true; +} + +bool StructTypePubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + StructType* p_type = + static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN +#if FASTCDR_VERSION_MAJOR == 1 + , eprosima::fastcdr::Cdr::CdrType::DDS_CDR +#endif // FASTCDR_VERSION_MAJOR == 1 + ); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +std::function StructTypePubSubType::getSerializedSizeProvider( + void* data, + DataRepresentationId_t data_representation) +{ + return [data, data_representation]() -> uint32_t + { +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 + }; +} + +void* StructTypePubSubType::createData() +{ + return reinterpret_cast(new StructType()); +} + +void StructTypePubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool StructTypePubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + static_cast(data); + static_cast(handle); + static_cast(force_md5); + + return false; +} + + + + + + + + + + +CompleteTestTypePubSubType::CompleteTestTypePubSubType() +{ + setName("eprosima::test::CompleteTestType"); + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(CompleteTestType::getMaxCdrSerializedSize()); +#else + eprosima_test_CompleteTestType_max_cdr_typesize; +#endif + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + m_typeSize = type_size + 4; /*encapsulation*/ + m_isGetKeyDefined = false; +} + +CompleteTestTypePubSubType::~CompleteTestTypePubSubType() +{ +} + +bool CompleteTestTypePubSubType::serialize( + void* data, + SerializedPayload_t* payload, + DataRepresentationId_t data_representation) +{ + CompleteTestType* p_type = + static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; +#if FASTCDR_VERSION_MAJOR > 1 + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); +#endif // FASTCDR_VERSION_MAJOR > 1 + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; +#if FASTCDR_VERSION_MAJOR > 1 + ser.set_dds_cdr_options({0, 0}); +#else + ser.setDDSCdrOptions(0); +#endif // FASTCDR_VERSION_MAJOR > 1 + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length +#if FASTCDR_VERSION_MAJOR == 1 + payload->length = static_cast(ser.getSerializedDataLength()); +#else + payload->length = static_cast(ser.get_serialized_data_length()); +#endif // FASTCDR_VERSION_MAJOR == 1 + return true; +} + +bool CompleteTestTypePubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + CompleteTestType* p_type = + static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN +#if FASTCDR_VERSION_MAJOR == 1 + , eprosima::fastcdr::Cdr::CdrType::DDS_CDR +#endif // FASTCDR_VERSION_MAJOR == 1 + ); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +std::function CompleteTestTypePubSubType::getSerializedSizeProvider( + void* data, + DataRepresentationId_t data_representation) +{ + return [data, data_representation]() -> uint32_t + { +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 + }; +} + +void* CompleteTestTypePubSubType::createData() +{ + return reinterpret_cast(new CompleteTestType()); +} + +void CompleteTestTypePubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool CompleteTestTypePubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + static_cast(data); + static_cast(handle); + static_cast(force_md5); + + return false; +} + + + + + + +KeyedCompleteTestTypePubSubType::KeyedCompleteTestTypePubSubType() +{ + setName("eprosima::test::KeyedCompleteTestType"); + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(KeyedCompleteTestType::getMaxCdrSerializedSize()); +#else + eprosima_test_KeyedCompleteTestType_max_cdr_typesize; +#endif + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + m_typeSize = type_size + 4; /*encapsulation*/ + m_isGetKeyDefined = true; + key_buffer_ = nullptr; + get_key_buffer_nts(); +} + +KeyedCompleteTestTypePubSubType::~KeyedCompleteTestTypePubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool KeyedCompleteTestTypePubSubType::serialize( + void* data, + SerializedPayload_t* payload, + DataRepresentationId_t data_representation) +{ + KeyedCompleteTestType* p_type = + static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; +#if FASTCDR_VERSION_MAJOR > 1 + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); +#endif // FASTCDR_VERSION_MAJOR > 1 + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; +#if FASTCDR_VERSION_MAJOR > 1 + ser.set_dds_cdr_options({0, 0}); +#else + ser.setDDSCdrOptions(0); +#endif // FASTCDR_VERSION_MAJOR > 1 + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length +#if FASTCDR_VERSION_MAJOR == 1 + payload->length = static_cast(ser.getSerializedDataLength()); +#else + payload->length = static_cast(ser.get_serialized_data_length()); +#endif // FASTCDR_VERSION_MAJOR == 1 + return true; +} + +bool KeyedCompleteTestTypePubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + KeyedCompleteTestType* p_type = + static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN +#if FASTCDR_VERSION_MAJOR == 1 + , eprosima::fastcdr::Cdr::CdrType::DDS_CDR +#endif // FASTCDR_VERSION_MAJOR == 1 + ); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +std::function KeyedCompleteTestTypePubSubType::getSerializedSizeProvider( + void* data, + DataRepresentationId_t data_representation) +{ + return [data, data_representation]() -> uint32_t + { +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 + }; +} + +void* KeyedCompleteTestTypePubSubType::createData() +{ + return reinterpret_cast(new KeyedCompleteTestType()); +} + +void KeyedCompleteTestTypePubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool KeyedCompleteTestTypePubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + std::lock_guard guard(compute_key_mtx_); + KeyedCompleteTestType* p_type = + static_cast(data); + + // Ensure the key buffer is reserved + unsigned char* key_buffer = get_key_buffer_nts(); + if (key_buffer == nullptr) + { + return false; + } + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer), + eprosima_test_KeyedCompleteTestType_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser( + fastbuffer, + eprosima::fastcdr::Cdr::BIG_ENDIANNESS, + eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else + eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 + if (force_md5 || eprosima_test_KeyedCompleteTestType_max_key_cdr_typesize > 16) + { + MD5 md5; + md5.init(); +#if FASTCDR_VERSION_MAJOR == 1 + md5.update(key_buffer, static_cast(ser.getSerializedDataLength())); +#else + md5.update(key_buffer, static_cast(ser.get_serialized_data_length())); +#endif // FASTCDR_VERSION_MAJOR == 1 + md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) { - setName("eprosima::test::KeyedCompleteTestType"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(KeyedCompleteTestType::getMaxCdrSerializedSize()); - #else - eprosima_test_KeyedCompleteTestType_max_cdr_typesize; - #endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = true; - uint32_t keyLength = eprosima_test_KeyedCompleteTestType_max_key_cdr_typesize > 16 ? eprosima_test_KeyedCompleteTestType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); + handle->value[i] = md5.digest[i]; } - - KeyedCompleteTestTypePubSubType::~KeyedCompleteTestTypePubSubType() - { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } - } - - bool KeyedCompleteTestTypePubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) + } + else + { + for (uint8_t i = 0; i < 16; ++i) { - KeyedCompleteTestType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); - #endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - #if FASTCDR_VERSION_MAJOR > 1 - ser.set_dds_cdr_options({0,0}); - #else - ser.setDDSCdrOptions(0); - #endif // FASTCDR_VERSION_MAJOR > 1 - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 - return true; + handle->value[i] = key_buffer[i]; } - - bool KeyedCompleteTestTypePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) - { - try - { - // Convert DATA to pointer of your type - KeyedCompleteTestType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); - - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; - } - - std::function KeyedCompleteTestTypePubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) - { - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; - } - - void* KeyedCompleteTestTypePubSubType::createData() - { - return reinterpret_cast(new KeyedCompleteTestType()); - } - - void KeyedCompleteTestTypePubSubType::deleteData( - void* data) - { - delete(reinterpret_cast(data)); - } - - bool KeyedCompleteTestTypePubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) - { - if (!m_isGetKeyDefined) - { - return false; - } - - KeyedCompleteTestType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - eprosima_test_KeyedCompleteTestType_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else - eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || eprosima_test_KeyedCompleteTestType_max_key_cdr_typesize > 16) - { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; - } - - - } //End of namespace test + } + return true; +} + +unsigned char* KeyedCompleteTestTypePubSubType::get_key_buffer_nts() +{ + // If already reserved, return + if (key_buffer_ != nullptr) + { + return key_buffer_; + } + + // Allocate the key buffer + uint32_t key_length = (std::max)(eprosima_test_KeyedCompleteTestType_max_key_cdr_typesize, 16u); + key_buffer_ = reinterpret_cast(calloc(key_length, 1u)); + return key_buffer_; +} + + +} //End of namespace test } //End of namespace eprosima diff --git a/fastdds_python/test/types/test_modulesPubSubTypes.h b/fastdds_python/test/types/test_modulesPubSubTypes.h index 50415835..2f6974f1 100644 --- a/fastdds_python/test/types/test_modulesPubSubTypes.h +++ b/fastdds_python/test/types/test_modulesPubSubTypes.h @@ -16,13 +16,15 @@ * @file test_modulesPubSubTypes.h * This header file contains the declaration of the serialization functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifndef _FAST_DDS_GENERATED_EPROSIMA_TEST_TEST_MODULES_PUBSUBTYPES_H_ #define _FAST_DDS_GENERATED_EPROSIMA_TEST_TEST_MODULES_PUBSUBTYPES_H_ +#include + #include #include #include @@ -37,100 +39,95 @@ Generated test_modules is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. #endif // GEN_API_VER -namespace eprosima -{ - namespace test - { - +namespace eprosima { +namespace test { - /*! - * @brief This class represents the TopicDataType of the type StructType defined by the user in the IDL file. - * @ingroup test_modules - */ - class StructTypePubSubType : public eprosima::fastdds::dds::TopicDataType - { - public: - typedef StructType type; +/*! + * @brief This class represents the TopicDataType of the type StructType defined by the user in the IDL file. + * @ingroup test_modules + */ +class StructTypePubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: - eProsima_user_DllExport StructTypePubSubType(); + typedef StructType type; - eProsima_user_DllExport ~StructTypePubSubType() override; + eProsima_user_DllExport StructTypePubSubType(); - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } + eProsima_user_DllExport ~StructTypePubSubType() override; - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + { + return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } + eProsima_user_DllExport bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data) override + { + return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport void deleteData( - void* data) override; + eProsima_user_DllExport void* createData() override; - #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } + eProsima_user_DllExport void deleteData( + void* data) override; - #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return false; + } - #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } - #endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + { + static_cast(data_representation); + return false; + } - #ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + static_cast(memory); + return false; + } - MD5 m_md5; - unsigned char* m_keyBuffer; +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - }; +}; @@ -140,187 +137,187 @@ namespace eprosima - /*! - * @brief This class represents the TopicDataType of the type CompleteTestType defined by the user in the IDL file. - * @ingroup test_modules - */ - class CompleteTestTypePubSubType : public eprosima::fastdds::dds::TopicDataType - { - public: +/*! + * @brief This class represents the TopicDataType of the type CompleteTestType defined by the user in the IDL file. + * @ingroup test_modules + */ +class CompleteTestTypePubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: - typedef CompleteTestType type; + typedef CompleteTestType type; - eProsima_user_DllExport CompleteTestTypePubSubType(); + eProsima_user_DllExport CompleteTestTypePubSubType(); - eProsima_user_DllExport ~CompleteTestTypePubSubType() override; + eProsima_user_DllExport ~CompleteTestTypePubSubType() override; - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + { + return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; + eProsima_user_DllExport bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data) override + { + return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; + eProsima_user_DllExport bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void* createData() override; - eProsima_user_DllExport void deleteData( - void* data) override; + eProsima_user_DllExport void deleteData( + void* data) override; - #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return false; + } - #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } + eProsima_user_DllExport inline bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + { + static_cast(data_representation); + return false; + } - #endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - #ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + static_cast(memory); + return false; + } - #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; +}; - }; +/*! + * @brief This class represents the TopicDataType of the type KeyedCompleteTestType defined by the user in the IDL file. + * @ingroup test_modules + */ +class KeyedCompleteTestTypePubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: - /*! - * @brief This class represents the TopicDataType of the type KeyedCompleteTestType defined by the user in the IDL file. - * @ingroup test_modules - */ - class KeyedCompleteTestTypePubSubType : public eprosima::fastdds::dds::TopicDataType - { - public: + typedef KeyedCompleteTestType type; - typedef KeyedCompleteTestType type; + eProsima_user_DllExport KeyedCompleteTestTypePubSubType(); - eProsima_user_DllExport KeyedCompleteTestTypePubSubType(); + eProsima_user_DllExport ~KeyedCompleteTestTypePubSubType() override; - eProsima_user_DllExport ~KeyedCompleteTestTypePubSubType() override; + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + { + return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data) override + { + return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; + eProsima_user_DllExport void* createData() override; - eProsima_user_DllExport void* createData() override; + eProsima_user_DllExport void deleteData( + void* data) override; - eProsima_user_DllExport void deleteData( - void* data) override; +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return false; + } - #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - #endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } - #ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - eProsima_user_DllExport inline bool is_plain() const override - { - return false; - } + eProsima_user_DllExport inline bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + { + static_cast(data_representation); + return false; + } - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - return false; - } +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN - #endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + static_cast(memory); + return false; + } - #ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eProsima_user_DllExport inline bool construct_sample( - void* memory) const override - { - static_cast(memory); - return false; - } +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE +private: - MD5 m_md5; - unsigned char* m_keyBuffer; + unsigned char* key_buffer_ = nullptr; + std::mutex compute_key_mtx_; - }; - } -} + unsigned char* get_key_buffer_nts(); +}; +} // namespace test +} // namespace eprosima #endif // _FAST_DDS_GENERATED_EPROSIMA_TEST_TEST_MODULES_PUBSUBTYPES_H_ diff --git a/fastdds_python/test/types/test_modulesPubSubTypes.i b/fastdds_python/test/types/test_modulesPubSubTypes.i index f3b1a453..09b019f0 100644 --- a/fastdds_python/test/types/test_modulesPubSubTypes.i +++ b/fastdds_python/test/types/test_modulesPubSubTypes.i @@ -16,7 +16,7 @@ * @file test_modulesPubSubTypes.i * This header file contains the SWIG interface of the serialization functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ %import(module="fastdds") "fastdds/dds/topic/TopicDataType.hpp"; diff --git a/fastdds_python/test/types/test_modulesv1.cxx b/fastdds_python/test/types/test_modulesv1.cxx index 9122a6fc..7d1b03b2 100644 --- a/fastdds_python/test/types/test_modulesv1.cxx +++ b/fastdds_python/test/types/test_modulesv1.cxx @@ -16,7 +16,7 @@ * @file test_modules.cpp * This source file contains the implementation of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifdef _WIN32 diff --git a/fastdds_python/test/types/test_modulesv1.h b/fastdds_python/test/types/test_modulesv1.h index 4bee87f3..0fb2e0af 100644 --- a/fastdds_python/test/types/test_modulesv1.h +++ b/fastdds_python/test/types/test_modulesv1.h @@ -16,7 +16,7 @@ * @file test_modules.h * This header file contains the declaration of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #include diff --git a/fastdds_python_examples/HelloWorldExample/CMakeLists.txt b/fastdds_python_examples/HelloWorldExample/CMakeLists.txt index 75aa5e75..67f75ec2 100644 --- a/fastdds_python_examples/HelloWorldExample/CMakeLists.txt +++ b/fastdds_python_examples/HelloWorldExample/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.20) # SWIG: use standard target name. if(POLICY CMP0078) @@ -27,6 +27,13 @@ find_package(fastrtps REQUIRED) set(CMAKE_POSITION_INDEPENDENT_CODE ON) +if(NOT WIN32) + # Default values for shared library suffix in MacOS + if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") + endif() +endif() + #Create library for C++ types add_library(${PROJECT_NAME} SHARED HelloWorld.cxx diff --git a/fastdds_python_examples/HelloWorldExample/HelloWorld.cxx b/fastdds_python_examples/HelloWorldExample/HelloWorld.cxx index 4b415d67..cb25330a 100644 --- a/fastdds_python_examples/HelloWorldExample/HelloWorld.cxx +++ b/fastdds_python_examples/HelloWorldExample/HelloWorld.cxx @@ -16,7 +16,7 @@ * @file HelloWorld.cpp * This source file contains the implementation of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifdef _WIN32 diff --git a/fastdds_python_examples/HelloWorldExample/HelloWorld.h b/fastdds_python_examples/HelloWorldExample/HelloWorld.h index 5cd0ddba..a721ac5a 100644 --- a/fastdds_python_examples/HelloWorldExample/HelloWorld.h +++ b/fastdds_python_examples/HelloWorldExample/HelloWorld.h @@ -16,7 +16,7 @@ * @file HelloWorld.h * This header file contains the declaration of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #include diff --git a/fastdds_python_examples/HelloWorldExample/HelloWorld.i b/fastdds_python_examples/HelloWorldExample/HelloWorld.i index 5af81f0a..5ea8840f 100644 --- a/fastdds_python_examples/HelloWorldExample/HelloWorld.i +++ b/fastdds_python_examples/HelloWorldExample/HelloWorld.i @@ -16,7 +16,7 @@ * @file HelloWorld.i * This header file contains the SWIG interface of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ %module HelloWorld diff --git a/fastdds_python_examples/HelloWorldExample/HelloWorldCdrAux.hpp b/fastdds_python_examples/HelloWorldExample/HelloWorldCdrAux.hpp index 9f346d30..ebbd2274 100644 --- a/fastdds_python_examples/HelloWorldExample/HelloWorldCdrAux.hpp +++ b/fastdds_python_examples/HelloWorldExample/HelloWorldCdrAux.hpp @@ -16,7 +16,7 @@ * @file HelloWorldCdrAux.hpp * This source file contains some definitions of CDR related functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ diff --git a/fastdds_python_examples/HelloWorldExample/HelloWorldCdrAux.ipp b/fastdds_python_examples/HelloWorldExample/HelloWorldCdrAux.ipp index 42e91f3c..60361ab9 100644 --- a/fastdds_python_examples/HelloWorldExample/HelloWorldCdrAux.ipp +++ b/fastdds_python_examples/HelloWorldExample/HelloWorldCdrAux.ipp @@ -16,7 +16,7 @@ * @file HelloWorldCdrAux.ipp * This source file contains some declarations of CDR related functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ diff --git a/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.cxx b/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.cxx index 85cb4778..6dbf2431 100644 --- a/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.cxx +++ b/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.cxx @@ -16,10 +16,13 @@ * @file HelloWorldPubSubTypes.cpp * This header file contains the implementation of the serialization functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ +#include +#include + #include #include "HelloWorldPubSubTypes.h" @@ -43,17 +46,10 @@ HelloWorldPubSubType::HelloWorldPubSubType() type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; - uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); } HelloWorldPubSubType::~HelloWorldPubSubType() { - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } } bool HelloWorldPubSubType::serialize( @@ -61,7 +57,8 @@ bool HelloWorldPubSubType::serialize( SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - HelloWorld* p_type = static_cast(data); + HelloWorld* p_type = + static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -83,6 +80,11 @@ bool HelloWorldPubSubType::serialize( ser.serialize_encapsulation(); // Serialize the object. ser << *p_type; +#if FASTCDR_VERSION_MAJOR > 1 + ser.set_dds_cdr_options({0, 0}); +#else + ser.setDDSCdrOptions(0); +#endif // FASTCDR_VERSION_MAJOR > 1 } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -105,7 +107,8 @@ bool HelloWorldPubSubType::deserialize( try { // Convert DATA to pointer of your type - HelloWorld* p_type = static_cast(data); + HelloWorld* p_type = + static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); @@ -177,45 +180,11 @@ bool HelloWorldPubSubType::getKey( InstanceHandle_t* handle, bool force_md5) { - if (!m_isGetKeyDefined) - { - return false; - } - - HelloWorld* p_type = static_cast(data); + static_cast(data); + static_cast(handle); + static_cast(force_md5); - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - HelloWorld_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; + return false; } + diff --git a/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.h b/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.h index cb61cd6b..9e0150ad 100644 --- a/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.h +++ b/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.h @@ -16,13 +16,15 @@ * @file HelloWorldPubSubTypes.h * This header file contains the declaration of the serialization functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ #define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ +#include + #include #include #include @@ -123,9 +125,6 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; - unsigned char* m_keyBuffer; - }; #endif // _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ diff --git a/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.i b/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.i index cac4f8c3..36660df4 100644 --- a/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.i +++ b/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.i @@ -16,7 +16,7 @@ * @file HelloWorldPubSubTypes.i * This header file contains the SWIG interface of the serialization functions. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ %import(module="fastdds") "fastdds/dds/topic/TopicDataType.hpp"; diff --git a/fastdds_python_examples/HelloWorldExample/HelloWorldv1.cxx b/fastdds_python_examples/HelloWorldExample/HelloWorldv1.cxx index 90e82ea8..a0462c5f 100644 --- a/fastdds_python_examples/HelloWorldExample/HelloWorldv1.cxx +++ b/fastdds_python_examples/HelloWorldExample/HelloWorldv1.cxx @@ -16,7 +16,7 @@ * @file HelloWorld.cpp * This source file contains the implementation of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #ifdef _WIN32 diff --git a/fastdds_python_examples/HelloWorldExample/HelloWorldv1.h b/fastdds_python_examples/HelloWorldExample/HelloWorldv1.h index 9f6f726e..00a28f8b 100644 --- a/fastdds_python_examples/HelloWorldExample/HelloWorldv1.h +++ b/fastdds_python_examples/HelloWorldExample/HelloWorldv1.h @@ -16,7 +16,7 @@ * @file HelloWorld.h * This header file contains the declaration of the described types in the IDL file. * - * This file was generated by the tool fastddsgen. + * This file was generated by the tool fastddsgen (version: 3.3.2). */ #include