diff --git a/fastdds_python/test/types/CMakeLists.txt b/fastdds_python/test/types/CMakeLists.txt index 12ad5204..7b976c24 100644 --- a/fastdds_python/test/types/CMakeLists.txt +++ b/fastdds_python/test/types/CMakeLists.txt @@ -116,7 +116,7 @@ target_link_libraries(${${PROJECT_NAME}_MODULE} ) # Find the installation path -execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))" +execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from sysconfig import get_path; print(get_path('purelib', vars={'base': '${CMAKE_INSTALL_PREFIX}'}))" OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE ) @@ -228,7 +228,7 @@ target_link_libraries(${${PROJECT_NAME}_MODULE} ) # Find the installation path -execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))" +execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from sysconfig import get_path; print(get_path('purelib', vars={'base': '${CMAKE_INSTALL_PREFIX}'}))" OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE ) @@ -341,7 +341,7 @@ target_link_libraries(${${PROJECT_NAME}_MODULE} ) # Find the installation path -execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))" +execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from sysconfig import get_path; print(get_path('purelib', vars={'base': '${CMAKE_INSTALL_PREFIX}'}))" OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE ) diff --git a/fastdds_python/test/types/test_complete.hpp b/fastdds_python/test/types/test_complete.hpp index f8976f42..8b3dd71e 100644 --- a/fastdds_python/test/types/test_complete.hpp +++ b/fastdds_python/test/types/test_complete.hpp @@ -16,7 +16,7 @@ * @file test_complete.hpp * This header file contains the declaration of the described types in the IDL file. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__TEST_COMPLETE_HPP diff --git a/fastdds_python/test/types/test_complete.i b/fastdds_python/test/types/test_complete.i index 0c46b886..809641e5 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 (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ %module(moduleimport="if __import__('os').name == 'nt': import win32api; win32api.LoadLibrary('test_complete.dll')\nif __package__ or '.' in __name__:\n from . import _test_completeWrapper\nelse:\n import _test_completeWrapper") test_complete @@ -2802,6 +2802,7 @@ namespace swig { // Include the class interfaces %include "test_complete.hpp" + // Include the corresponding TopicDataType %include "test_completePubSubTypes.i" diff --git a/fastdds_python/test/types/test_completeCdrAux.hpp b/fastdds_python/test/types/test_completeCdrAux.hpp index 4f91d26f..e75d26e6 100644 --- a/fastdds_python/test/types/test_completeCdrAux.hpp +++ b/fastdds_python/test/types/test_completeCdrAux.hpp @@ -16,13 +16,14 @@ * @file test_completeCdrAux.hpp * This source file contains some definitions of CDR related functions. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__TEST_COMPLETECDRAUX_HPP #define FAST_DDS_GENERATED__TEST_COMPLETECDRAUX_HPP #include "test_complete.hpp" + constexpr uint32_t CompleteTestType_max_cdr_typesize {8164UL}; constexpr uint32_t CompleteTestType_max_key_cdr_typesize {0UL}; diff --git a/fastdds_python/test/types/test_completeCdrAux.ipp b/fastdds_python/test/types/test_completeCdrAux.ipp index e4801e18..f38db21a 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 (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #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 13d7c947..a90b1c78 100644 --- a/fastdds_python/test/types/test_completePubSubTypes.cxx +++ b/fastdds_python/test/types/test_completePubSubTypes.cxx @@ -16,11 +16,14 @@ * @file test_completePubSubTypes.cpp * This header file contains the implementation of the serialization functions. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #include "test_completePubSubTypes.hpp" +#include +#include + #include #include @@ -38,17 +41,10 @@ StructTypePubSubType::StructTypePubSubType() type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ max_serialized_type_size = type_size + 4; /*encapsulation*/ is_compute_key_provided = false; - uint32_t key_length = StructType_max_key_cdr_typesize > 16 ? StructType_max_key_cdr_typesize : 16; - key_buffer_ = reinterpret_cast(malloc(key_length)); - memset(key_buffer_, 0, key_length); } StructTypePubSubType::~StructTypePubSubType() { - if (key_buffer_ != nullptr) - { - free(key_buffer_); - } } bool StructTypePubSubType::serialize( @@ -56,7 +52,8 @@ bool StructTypePubSubType::serialize( SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const ::StructType* p_type = static_cast(data); + const ::StructType* p_type = + static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); @@ -76,7 +73,7 @@ bool StructTypePubSubType::serialize( ser.serialize_encapsulation(); // Serialize the object. ser << *p_type; - ser.set_dds_cdr_options({0,0}); + ser.set_dds_cdr_options({0, 0}); } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -95,7 +92,8 @@ bool StructTypePubSubType::deserialize( try { // Convert DATA to pointer of your type - ::StructType* p_type = static_cast<::StructType*>(data); + ::StructType* p_type = + static_cast<::StructType*>(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); @@ -128,9 +126,10 @@ uint32_t StructTypePubSubType::calculate_serialized_size( 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*/; + const ::StructType* p_type = + static_cast(data); + auto calc_size = calculator.calculate_serialized_size(*p_type, current_alignment); + return static_cast(calc_size) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -154,16 +153,9 @@ bool StructTypePubSubType::compute_key( InstanceHandle_t& handle, bool force_md5) { - if (!is_compute_key_provided) - { - return false; - } - - ::StructType data; - if (deserialize(payload, static_cast(&data))) - { - return compute_key(static_cast(&data), handle, force_md5); - } + static_cast(payload); + static_cast(handle); + static_cast(force_md5); return false; } @@ -173,39 +165,11 @@ bool StructTypePubSubType::compute_key( InstanceHandle_t& handle, bool force_md5) { - if (!is_compute_key_provided) - { - return false; - } + static_cast(data); + static_cast(handle); + static_cast(force_md5); - const ::StructType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), - StructType_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); - ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); - eprosima::fastcdr::serialize_key(ser, *p_type); - if (force_md5 || StructType_max_key_cdr_typesize > 16) - { - md5_.init(); - md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); - md5_.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle.value[i] = md5_.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle.value[i] = key_buffer_[i]; - } - } - return true; + return false; } void StructTypePubSubType::register_type_object_representation() @@ -220,17 +184,10 @@ CompleteTestTypePubSubType::CompleteTestTypePubSubType() type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ max_serialized_type_size = type_size + 4; /*encapsulation*/ is_compute_key_provided = false; - uint32_t key_length = CompleteTestType_max_key_cdr_typesize > 16 ? CompleteTestType_max_key_cdr_typesize : 16; - key_buffer_ = reinterpret_cast(malloc(key_length)); - memset(key_buffer_, 0, key_length); } CompleteTestTypePubSubType::~CompleteTestTypePubSubType() { - if (key_buffer_ != nullptr) - { - free(key_buffer_); - } } bool CompleteTestTypePubSubType::serialize( @@ -238,7 +195,8 @@ bool CompleteTestTypePubSubType::serialize( SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const ::CompleteTestType* p_type = static_cast(data); + const ::CompleteTestType* p_type = + static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); @@ -258,7 +216,7 @@ bool CompleteTestTypePubSubType::serialize( ser.serialize_encapsulation(); // Serialize the object. ser << *p_type; - ser.set_dds_cdr_options({0,0}); + ser.set_dds_cdr_options({0, 0}); } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -277,7 +235,8 @@ bool CompleteTestTypePubSubType::deserialize( try { // Convert DATA to pointer of your type - ::CompleteTestType* p_type = static_cast<::CompleteTestType*>(data); + ::CompleteTestType* p_type = + static_cast<::CompleteTestType*>(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); @@ -310,9 +269,10 @@ uint32_t CompleteTestTypePubSubType::calculate_serialized_size( 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*/; + const ::CompleteTestType* p_type = + static_cast(data); + auto calc_size = calculator.calculate_serialized_size(*p_type, current_alignment); + return static_cast(calc_size) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -336,16 +296,9 @@ bool CompleteTestTypePubSubType::compute_key( InstanceHandle_t& handle, bool force_md5) { - if (!is_compute_key_provided) - { - return false; - } - - ::CompleteTestType data; - if (deserialize(payload, static_cast(&data))) - { - return compute_key(static_cast(&data), handle, force_md5); - } + static_cast(payload); + static_cast(handle); + static_cast(force_md5); return false; } @@ -355,39 +308,11 @@ bool CompleteTestTypePubSubType::compute_key( InstanceHandle_t& handle, bool force_md5) { - if (!is_compute_key_provided) - { - return false; - } - - const ::CompleteTestType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), - CompleteTestType_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::XCDRv2); - ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); - eprosima::fastcdr::serialize_key(ser, *p_type); - if (force_md5 || CompleteTestType_max_key_cdr_typesize > 16) - { - md5_.init(); - md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); - md5_.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle.value[i] = md5_.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle.value[i] = key_buffer_[i]; - } - } - return true; + return false; } void CompleteTestTypePubSubType::register_type_object_representation() @@ -402,9 +327,8 @@ KeyedCompleteTestTypePubSubType::KeyedCompleteTestTypePubSubType() type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ max_serialized_type_size = type_size + 4; /*encapsulation*/ is_compute_key_provided = true; - uint32_t key_length = KeyedCompleteTestType_max_key_cdr_typesize > 16 ? KeyedCompleteTestType_max_key_cdr_typesize : 16; - key_buffer_ = reinterpret_cast(malloc(key_length)); - memset(key_buffer_, 0, key_length); + key_buffer_ = nullptr; + get_key_buffer_nts(); } KeyedCompleteTestTypePubSubType::~KeyedCompleteTestTypePubSubType() @@ -420,7 +344,8 @@ bool KeyedCompleteTestTypePubSubType::serialize( SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const ::KeyedCompleteTestType* p_type = static_cast(data); + const ::KeyedCompleteTestType* p_type = + static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); @@ -440,7 +365,7 @@ bool KeyedCompleteTestTypePubSubType::serialize( ser.serialize_encapsulation(); // Serialize the object. ser << *p_type; - ser.set_dds_cdr_options({0,0}); + ser.set_dds_cdr_options({0, 0}); } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -459,7 +384,8 @@ bool KeyedCompleteTestTypePubSubType::deserialize( try { // Convert DATA to pointer of your type - ::KeyedCompleteTestType* p_type = static_cast<::KeyedCompleteTestType*>(data); + ::KeyedCompleteTestType* p_type = + static_cast<::KeyedCompleteTestType*>(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); @@ -492,9 +418,10 @@ uint32_t KeyedCompleteTestTypePubSubType::calculate_serialized_size( 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*/; + const ::KeyedCompleteTestType* p_type = + static_cast(data); + auto calc_size = calculator.calculate_serialized_size(*p_type, current_alignment); + return static_cast(calc_size) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -518,17 +445,11 @@ bool KeyedCompleteTestTypePubSubType::compute_key( InstanceHandle_t& handle, bool force_md5) { - if (!is_compute_key_provided) - { - return false; - } - ::KeyedCompleteTestType data; if (deserialize(payload, static_cast(&data))) { return compute_key(static_cast(&data), handle, force_md5); } - return false; } @@ -537,41 +458,63 @@ bool KeyedCompleteTestTypePubSubType::compute_key( InstanceHandle_t& handle, bool force_md5) { - if (!is_compute_key_provided) + std::lock_guard guard(compute_key_mtx_); + const ::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; } - const ::KeyedCompleteTestType* p_type = static_cast(data); - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), + 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::XCDRv2); + eprosima::fastcdr::Cdr ser( + fastbuffer, + eprosima::fastcdr::Cdr::BIG_ENDIANNESS, + eprosima::fastcdr::CdrVersion::XCDRv2); ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); eprosima::fastcdr::serialize_key(ser, *p_type); if (force_md5 || KeyedCompleteTestType_max_key_cdr_typesize > 16) { - md5_.init(); - md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); - md5_.finalize(); + eprosima::fastdds::MD5 md5; + md5.init(); + md5.update(key_buffer, static_cast(ser.get_serialized_data_length())); + md5.finalize(); for (uint8_t i = 0; i < 16; ++i) { - handle.value[i] = md5_.digest[i]; + handle.value[i] = md5.digest[i]; } } else { for (uint8_t i = 0; i < 16; ++i) { - handle.value[i] = key_buffer_[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_; +} + void KeyedCompleteTestTypePubSubType::register_type_object_representation() { register_KeyedCompleteTestType_type_identifier(type_identifiers_); diff --git a/fastdds_python/test/types/test_completePubSubTypes.hpp b/fastdds_python/test/types/test_completePubSubTypes.hpp index 6c99920e..a50b5db9 100644 --- a/fastdds_python/test/types/test_completePubSubTypes.hpp +++ b/fastdds_python/test/types/test_completePubSubTypes.hpp @@ -16,13 +16,15 @@ * @file test_completePubSubTypes.hpp * This header file contains the declaration of the serialization functions. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__TEST_COMPLETE_PUBSUBTYPES_HPP #define FAST_DDS_GENERATED__TEST_COMPLETE_PUBSUBTYPES_HPP +#include + #include #include #include @@ -115,9 +117,6 @@ class StructTypePubSubType : public eprosima::fastdds::dds::TopicDataType private: - eprosima::fastdds::MD5 md5_; - unsigned char* key_buffer_; - }; @@ -197,9 +196,6 @@ class CompleteTestTypePubSubType : public eprosima::fastdds::dds::TopicDataType private: - eprosima::fastdds::MD5 md5_; - unsigned char* key_buffer_; - }; @@ -279,8 +275,10 @@ class KeyedCompleteTestTypePubSubType : public eprosima::fastdds::dds::TopicData private: - eprosima::fastdds::MD5 md5_; - unsigned char* key_buffer_; + unsigned char* key_buffer_ = nullptr; + std::mutex compute_key_mtx_; + + unsigned char* get_key_buffer_nts(); }; diff --git a/fastdds_python/test/types/test_completePubSubTypes.i b/fastdds_python/test/types/test_completePubSubTypes.i index 65cd385b..ffbebdd3 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 (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ %import(module="fastdds") "fastdds/dds/topic/TopicDataType.hpp"; diff --git a/fastdds_python/test/types/test_completeTypeObjectSupport.cxx b/fastdds_python/test/types/test_completeTypeObjectSupport.cxx index 7f5bea8b..39e8fbd6 100644 --- a/fastdds_python/test/types/test_completeTypeObjectSupport.cxx +++ b/fastdds_python/test/types/test_completeTypeObjectSupport.cxx @@ -16,7 +16,7 @@ * @file test_completeTypeObjectSupport.cxx * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #include "test_completeTypeObjectSupport.hpp" @@ -32,6 +32,7 @@ #include #include #include + #include "test_complete.hpp" #include "test_included_modules.hpp" diff --git a/fastdds_python/test/types/test_completeTypeObjectSupport.hpp b/fastdds_python/test/types/test_completeTypeObjectSupport.hpp index 52936ef4..2289bb95 100644 --- a/fastdds_python/test/types/test_completeTypeObjectSupport.hpp +++ b/fastdds_python/test/types/test_completeTypeObjectSupport.hpp @@ -16,7 +16,7 @@ * @file test_completeTypeObjectSupport.hpp * Header file containing the API required to register the TypeObject representation of the described types in the IDL file * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__TEST_COMPLETE_TYPE_OBJECT_SUPPORT_HPP diff --git a/fastdds_python/test/types/test_included_modules.hpp b/fastdds_python/test/types/test_included_modules.hpp index 41c7101d..bfbcbfcf 100644 --- a/fastdds_python/test/types/test_included_modules.hpp +++ b/fastdds_python/test/types/test_included_modules.hpp @@ -16,7 +16,7 @@ * @file test_included_modules.hpp * This header file contains the declaration of the described types in the IDL file. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__EPROSIMA_TEST2_TEST_INCLUDED_MODULES_HPP diff --git a/fastdds_python/test/types/test_included_modules.i b/fastdds_python/test/types/test_included_modules.i index a886ae63..b759ade1 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 (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ %module(moduleimport="if __import__('os').name == 'nt': import win32api; win32api.LoadLibrary('test_included_modules.dll')\nif __package__ or '.' in __name__:\n from . import _test_included_modulesWrapper\nelse:\n import _test_included_modulesWrapper") test_included_modules @@ -254,6 +254,7 @@ namespace swig { // Include the class interfaces %include "test_included_modules.hpp" + // Include the corresponding TopicDataType %include "test_included_modulesPubSubTypes.i" diff --git a/fastdds_python/test/types/test_included_modulesCdrAux.hpp b/fastdds_python/test/types/test_included_modulesCdrAux.hpp index 86a093b0..5b99861d 100644 --- a/fastdds_python/test/types/test_included_modulesCdrAux.hpp +++ b/fastdds_python/test/types/test_included_modulesCdrAux.hpp @@ -16,13 +16,14 @@ * @file test_included_modulesCdrAux.hpp * This source file contains some definitions of CDR related functions. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__EPROSIMA_TEST2_TEST_INCLUDED_MODULESCDRAUX_HPP #define FAST_DDS_GENERATED__EPROSIMA_TEST2_TEST_INCLUDED_MODULESCDRAUX_HPP #include "test_included_modules.hpp" + constexpr uint32_t eprosima_test2_StructType2_max_cdr_typesize {328UL}; constexpr uint32_t eprosima_test2_StructType2_max_key_cdr_typesize {0UL}; diff --git a/fastdds_python/test/types/test_included_modulesCdrAux.ipp b/fastdds_python/test/types/test_included_modulesCdrAux.ipp index 2f13cdfe..701b4304 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 (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #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 ee8efd8e..ed29a0d0 100644 --- a/fastdds_python/test/types/test_included_modulesPubSubTypes.cxx +++ b/fastdds_python/test/types/test_included_modulesPubSubTypes.cxx @@ -16,11 +16,14 @@ * @file test_included_modulesPubSubTypes.cpp * This header file contains the implementation of the serialization functions. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #include "test_included_modulesPubSubTypes.hpp" +#include +#include + #include #include @@ -32,190 +35,151 @@ using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; namespace eprosima { - namespace test2 { - StructType2PubSubType::StructType2PubSubType() - { - set_name("eprosima::test2::StructType2"); - uint32_t type_size = eprosima_test2_StructType2_max_cdr_typesize; - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - max_serialized_type_size = type_size + 4; /*encapsulation*/ - is_compute_key_provided = false; - uint32_t key_length = eprosima_test2_StructType2_max_key_cdr_typesize > 16 ? eprosima_test2_StructType2_max_key_cdr_typesize : 16; - key_buffer_ = reinterpret_cast(malloc(key_length)); - memset(key_buffer_, 0, key_length); - } - - StructType2PubSubType::~StructType2PubSubType() - { - if (key_buffer_ != nullptr) - { - free(key_buffer_); - } - } - - bool StructType2PubSubType::serialize( - const void* const data, - SerializedPayload_t& payload, - DataRepresentationId_t data_representation) - { - const ::eprosima::test2::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; - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - ser.set_dds_cdr_options({0,0}); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length - payload.length = static_cast(ser.get_serialized_data_length()); - return true; - } - - bool StructType2PubSubType::deserialize( - SerializedPayload_t& payload, - void* data) - { - try - { - // Convert DATA to pointer of your type - ::eprosima::test2::StructType2* p_type = static_cast<::eprosima::test2::StructType2*>(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); - - // 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; - } - - uint32_t StructType2PubSubType::calculate_serialized_size( - const void* const data, - DataRepresentationId_t data_representation) - { - 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; - } - } - - void* StructType2PubSubType::create_data() - { - return reinterpret_cast(new ::eprosima::test2::StructType2()); - } - - void StructType2PubSubType::delete_data( - void* data) - { - delete(reinterpret_cast<::eprosima::test2::StructType2*>(data)); - } - - bool StructType2PubSubType::compute_key( - SerializedPayload_t& payload, - InstanceHandle_t& handle, - bool force_md5) - { - if (!is_compute_key_provided) - { - return false; - } - - ::eprosima::test2::StructType2 data; - if (deserialize(payload, static_cast(&data))) - { - return compute_key(static_cast(&data), handle, force_md5); - } - - return false; - } - - bool StructType2PubSubType::compute_key( - const void* const data, - InstanceHandle_t& handle, - bool force_md5) - { - if (!is_compute_key_provided) - { - return false; - } - - const ::eprosima::test2::StructType2* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), - 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::XCDRv2); - ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); - eprosima::fastcdr::serialize_key(ser, *p_type); - if (force_md5 || eprosima_test2_StructType2_max_key_cdr_typesize > 16) - { - md5_.init(); - md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); - md5_.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle.value[i] = md5_.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle.value[i] = key_buffer_[i]; - } - } - return true; - } - - void StructType2PubSubType::register_type_object_representation() - { - register_StructType2_type_identifier(type_identifiers_); - } - - } // namespace test2 +namespace test2 { +StructType2PubSubType::StructType2PubSubType() +{ + set_name("eprosima::test2::StructType2"); + uint32_t type_size = eprosima_test2_StructType2_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; +} + +StructType2PubSubType::~StructType2PubSubType() +{ +} + +bool StructType2PubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const ::eprosima::test2::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; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + ser.set_dds_cdr_options({0, 0}); + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool StructType2PubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + ::eprosima::test2::StructType2* p_type = + static_cast<::eprosima::test2::StructType2*>(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); + + // 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; +} + +uint32_t StructType2PubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + 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}; + const ::eprosima::test2::StructType2* p_type = + static_cast(data); + auto calc_size = calculator.calculate_serialized_size(*p_type, current_alignment); + return static_cast(calc_size) + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* StructType2PubSubType::create_data() +{ + return reinterpret_cast(new ::eprosima::test2::StructType2()); +} + +void StructType2PubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast<::eprosima::test2::StructType2*>(data)); +} + +bool StructType2PubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + static_cast(payload); + static_cast(handle); + static_cast(force_md5); + + return false; +} + +bool StructType2PubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + static_cast(data); + static_cast(handle); + static_cast(force_md5); + + return false; +} + +void StructType2PubSubType::register_type_object_representation() +{ + register_StructType2_type_identifier(type_identifiers_); +} + +} // namespace test2 } // namespace eprosima diff --git a/fastdds_python/test/types/test_included_modulesPubSubTypes.hpp b/fastdds_python/test/types/test_included_modulesPubSubTypes.hpp index e88a56b0..7f25b18b 100644 --- a/fastdds_python/test/types/test_included_modulesPubSubTypes.hpp +++ b/fastdds_python/test/types/test_included_modulesPubSubTypes.hpp @@ -16,13 +16,15 @@ * @file test_included_modulesPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__EPROSIMA_TEST2_TEST_INCLUDED_MODULES_PUBSUBTYPES_HPP #define FAST_DDS_GENERATED__EPROSIMA_TEST2_TEST_INCLUDED_MODULES_PUBSUBTYPES_HPP +#include + #include #include #include @@ -37,94 +39,89 @@ Generated test_included_modules is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. #endif // FASTDDS_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 ::eprosima::test2::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 ::eprosima::test2::StructType2 type; - eProsima_user_DllExport ~StructType2PubSubType() override; + eProsima_user_DllExport StructType2PubSubType(); - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t& payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport ~StructType2PubSubType() override; - eProsima_user_DllExport bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t& payload, - void* data) override; + eProsima_user_DllExport bool serialize( + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport uint32_t calculate_serialized_size( - const void* const data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport bool deserialize( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + void* data) override; - eProsima_user_DllExport bool compute_key( - eprosima::fastdds::rtps::SerializedPayload_t& payload, - eprosima::fastdds::rtps::InstanceHandle_t& ihandle, - bool force_md5 = false) override; + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool compute_key( - const void* const data, - eprosima::fastdds::rtps::InstanceHandle_t& ihandle, - bool force_md5 = false) override; + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport void* create_data() override; + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport void delete_data( - void* data) override; + eProsima_user_DllExport void* create_data() override; - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() override; + eProsima_user_DllExport void delete_data( + void* data) override; - #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() 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 +#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 - #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; + } - private: +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 md5_; - unsigned char* key_buffer_; +private: - }; +}; - } // namespace test2 -} // namespace eprosima +} // namespace test2 +} // namespace eprosima #endif // FAST_DDS_GENERATED__EPROSIMA_TEST2_TEST_INCLUDED_MODULES_PUBSUBTYPES_HPP diff --git a/fastdds_python/test/types/test_included_modulesPubSubTypes.i b/fastdds_python/test/types/test_included_modulesPubSubTypes.i index c68ee814..68f108b4 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 (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ %import(module="fastdds") "fastdds/dds/topic/TopicDataType.hpp"; diff --git a/fastdds_python/test/types/test_included_modulesTypeObjectSupport.cxx b/fastdds_python/test/types/test_included_modulesTypeObjectSupport.cxx index 912b15d1..9bedb78b 100644 --- a/fastdds_python/test/types/test_included_modulesTypeObjectSupport.cxx +++ b/fastdds_python/test/types/test_included_modulesTypeObjectSupport.cxx @@ -16,7 +16,7 @@ * @file test_included_modulesTypeObjectSupport.cxx * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #include "test_included_modulesTypeObjectSupport.hpp" @@ -32,6 +32,7 @@ #include #include #include + #include "test_included_modules.hpp" diff --git a/fastdds_python/test/types/test_included_modulesTypeObjectSupport.hpp b/fastdds_python/test/types/test_included_modulesTypeObjectSupport.hpp index aad59e12..080eac95 100644 --- a/fastdds_python/test/types/test_included_modulesTypeObjectSupport.hpp +++ b/fastdds_python/test/types/test_included_modulesTypeObjectSupport.hpp @@ -16,7 +16,7 @@ * @file test_included_modulesTypeObjectSupport.hpp * Header file containing the API required to register the TypeObject representation of the described types in the IDL file * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__EPROSIMA_TEST2_TEST_INCLUDED_MODULES_TYPE_OBJECT_SUPPORT_HPP diff --git a/fastdds_python/test/types/test_modules.hpp b/fastdds_python/test/types/test_modules.hpp index dbe66283..dcf93201 100644 --- a/fastdds_python/test/types/test_modules.hpp +++ b/fastdds_python/test/types/test_modules.hpp @@ -16,7 +16,7 @@ * @file test_modules.hpp * This header file contains the declaration of the described types in the IDL file. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__EPROSIMA_TEST_TEST_MODULES_HPP diff --git a/fastdds_python/test/types/test_modules.i b/fastdds_python/test/types/test_modules.i index f85b10cc..21e3b5ea 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 (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ %module(moduleimport="if __import__('os').name == 'nt': import win32api; win32api.LoadLibrary('test_modules.dll')\nif __package__ or '.' in __name__:\n from . import _test_modulesWrapper\nelse:\n import _test_modulesWrapper") test_modules @@ -2790,6 +2790,7 @@ namespace swig { // Include the class interfaces %include "test_modules.hpp" + // Include the corresponding TopicDataType %include "test_modulesPubSubTypes.i" diff --git a/fastdds_python/test/types/test_modulesCdrAux.hpp b/fastdds_python/test/types/test_modulesCdrAux.hpp index b47b9d33..2615afcc 100644 --- a/fastdds_python/test/types/test_modulesCdrAux.hpp +++ b/fastdds_python/test/types/test_modulesCdrAux.hpp @@ -16,13 +16,14 @@ * @file test_modulesCdrAux.hpp * This source file contains some definitions of CDR related functions. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__EPROSIMA_TEST_TEST_MODULESCDRAUX_HPP #define FAST_DDS_GENERATED__EPROSIMA_TEST_TEST_MODULESCDRAUX_HPP #include "test_modules.hpp" + constexpr uint32_t eprosima_test_KeyedCompleteTestType_max_cdr_typesize {4884UL}; constexpr uint32_t eprosima_test_KeyedCompleteTestType_max_key_cdr_typesize {4UL}; diff --git a/fastdds_python/test/types/test_modulesCdrAux.ipp b/fastdds_python/test/types/test_modulesCdrAux.ipp index 0d65814d..36ef02cc 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 (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #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 32efe403..d033fcd6 100644 --- a/fastdds_python/test/types/test_modulesPubSubTypes.cxx +++ b/fastdds_python/test/types/test_modulesPubSubTypes.cxx @@ -16,11 +16,14 @@ * @file test_modulesPubSubTypes.cpp * This header file contains the implementation of the serialization functions. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #include "test_modulesPubSubTypes.hpp" +#include +#include + #include #include @@ -32,554 +35,494 @@ using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; namespace eprosima { - namespace test { - StructTypePubSubType::StructTypePubSubType() - { - set_name("eprosima::test::StructType"); - uint32_t type_size = eprosima_test_StructType_max_cdr_typesize; - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - max_serialized_type_size = type_size + 4; /*encapsulation*/ - is_compute_key_provided = false; - uint32_t key_length = eprosima_test_StructType_max_key_cdr_typesize > 16 ? eprosima_test_StructType_max_key_cdr_typesize : 16; - key_buffer_ = reinterpret_cast(malloc(key_length)); - memset(key_buffer_, 0, key_length); - } - - StructTypePubSubType::~StructTypePubSubType() - { - if (key_buffer_ != nullptr) - { - free(key_buffer_); - } - } - - bool StructTypePubSubType::serialize( - const void* const data, - SerializedPayload_t& payload, - DataRepresentationId_t data_representation) - { - const ::eprosima::test::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; - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - ser.set_dds_cdr_options({0,0}); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length - payload.length = static_cast(ser.get_serialized_data_length()); - return true; - } - - bool StructTypePubSubType::deserialize( - SerializedPayload_t& payload, - void* data) - { - try - { - // Convert DATA to pointer of your type - ::eprosima::test::StructType* p_type = static_cast<::eprosima::test::StructType*>(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); - - // 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; - } - - uint32_t StructTypePubSubType::calculate_serialized_size( - const void* const data, - DataRepresentationId_t data_representation) - { - 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; - } - } - - void* StructTypePubSubType::create_data() - { - return reinterpret_cast(new ::eprosima::test::StructType()); - } - - void StructTypePubSubType::delete_data( - void* data) - { - delete(reinterpret_cast<::eprosima::test::StructType*>(data)); - } - - bool StructTypePubSubType::compute_key( - SerializedPayload_t& payload, - InstanceHandle_t& handle, - bool force_md5) +namespace test { +StructTypePubSubType::StructTypePubSubType() +{ + set_name("eprosima::test::StructType"); + uint32_t type_size = eprosima_test_StructType_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; +} + +StructTypePubSubType::~StructTypePubSubType() +{ +} + +bool StructTypePubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const ::eprosima::test::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; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + ser.set_dds_cdr_options({0, 0}); + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool StructTypePubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + ::eprosima::test::StructType* p_type = + static_cast<::eprosima::test::StructType*>(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); + + // 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; +} + +uint32_t StructTypePubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + 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}; + const ::eprosima::test::StructType* p_type = + static_cast(data); + auto calc_size = calculator.calculate_serialized_size(*p_type, current_alignment); + return static_cast(calc_size) + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* StructTypePubSubType::create_data() +{ + return reinterpret_cast(new ::eprosima::test::StructType()); +} + +void StructTypePubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast<::eprosima::test::StructType*>(data)); +} + +bool StructTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + static_cast(payload); + static_cast(handle); + static_cast(force_md5); + + return false; +} + +bool StructTypePubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + static_cast(data); + static_cast(handle); + static_cast(force_md5); + + return false; +} + +void StructTypePubSubType::register_type_object_representation() +{ + register_StructType_type_identifier(type_identifiers_); +} + +CompleteTestTypePubSubType::CompleteTestTypePubSubType() +{ + set_name("eprosima::test::CompleteTestType"); + uint32_t type_size = eprosima_test_CompleteTestType_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = false; +} + +CompleteTestTypePubSubType::~CompleteTestTypePubSubType() +{ +} + +bool CompleteTestTypePubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const ::eprosima::test::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; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + ser.set_dds_cdr_options({0, 0}); + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool CompleteTestTypePubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + ::eprosima::test::CompleteTestType* p_type = + static_cast<::eprosima::test::CompleteTestType*>(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); + + // 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; +} + +uint32_t CompleteTestTypePubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + 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}; + const ::eprosima::test::CompleteTestType* p_type = + static_cast(data); + auto calc_size = calculator.calculate_serialized_size(*p_type, current_alignment); + return static_cast(calc_size) + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* CompleteTestTypePubSubType::create_data() +{ + return reinterpret_cast(new ::eprosima::test::CompleteTestType()); +} + +void CompleteTestTypePubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast<::eprosima::test::CompleteTestType*>(data)); +} + +bool CompleteTestTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + static_cast(payload); + static_cast(handle); + static_cast(force_md5); + + return false; +} + +bool CompleteTestTypePubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + static_cast(data); + static_cast(handle); + static_cast(force_md5); + + return false; +} + +void CompleteTestTypePubSubType::register_type_object_representation() +{ + register_CompleteTestType_type_identifier(type_identifiers_); +} + +KeyedCompleteTestTypePubSubType::KeyedCompleteTestTypePubSubType() +{ + set_name("eprosima::test::KeyedCompleteTestType"); + uint32_t type_size = eprosima_test_KeyedCompleteTestType_max_cdr_typesize; + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + max_serialized_type_size = type_size + 4; /*encapsulation*/ + is_compute_key_provided = true; + key_buffer_ = nullptr; + get_key_buffer_nts(); +} + +KeyedCompleteTestTypePubSubType::~KeyedCompleteTestTypePubSubType() +{ + if (key_buffer_ != nullptr) + { + free(key_buffer_); + } +} + +bool KeyedCompleteTestTypePubSubType::serialize( + const void* const data, + SerializedPayload_t& payload, + DataRepresentationId_t data_representation) +{ + const ::eprosima::test::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; + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + ser.set_dds_cdr_options({0, 0}); + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload.length = static_cast(ser.get_serialized_data_length()); + return true; +} + +bool KeyedCompleteTestTypePubSubType::deserialize( + SerializedPayload_t& payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + ::eprosima::test::KeyedCompleteTestType* p_type = + static_cast<::eprosima::test::KeyedCompleteTestType*>(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); + + // 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; +} + +uint32_t KeyedCompleteTestTypePubSubType::calculate_serialized_size( + const void* const data, + DataRepresentationId_t data_representation) +{ + 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}; + const ::eprosima::test::KeyedCompleteTestType* p_type = + static_cast(data); + auto calc_size = calculator.calculate_serialized_size(*p_type, current_alignment); + return static_cast(calc_size) + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +} + +void* KeyedCompleteTestTypePubSubType::create_data() +{ + return reinterpret_cast(new ::eprosima::test::KeyedCompleteTestType()); +} + +void KeyedCompleteTestTypePubSubType::delete_data( + void* data) +{ + delete(reinterpret_cast<::eprosima::test::KeyedCompleteTestType*>(data)); +} + +bool KeyedCompleteTestTypePubSubType::compute_key( + SerializedPayload_t& payload, + InstanceHandle_t& handle, + bool force_md5) +{ + ::eprosima::test::KeyedCompleteTestType data; + if (deserialize(payload, static_cast(&data))) + { + return compute_key(static_cast(&data), handle, force_md5); + } + return false; +} + +bool KeyedCompleteTestTypePubSubType::compute_key( + const void* const data, + InstanceHandle_t& handle, + bool force_md5) +{ + std::lock_guard guard(compute_key_mtx_); + const ::eprosima::test::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::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); + eprosima::fastcdr::serialize_key(ser, *p_type); + if (force_md5 || eprosima_test_KeyedCompleteTestType_max_key_cdr_typesize > 16) + { + eprosima::fastdds::MD5 md5; + md5.init(); + md5.update(key_buffer, static_cast(ser.get_serialized_data_length())); + md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) { - if (!is_compute_key_provided) - { - return false; - } - - ::eprosima::test::StructType data; - if (deserialize(payload, static_cast(&data))) - { - return compute_key(static_cast(&data), handle, force_md5); - } - - return false; + handle.value[i] = md5.digest[i]; } - - bool StructTypePubSubType::compute_key( - const void* const data, - InstanceHandle_t& handle, - bool force_md5) - { - if (!is_compute_key_provided) - { - return false; - } - - const ::eprosima::test::StructType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), - 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::XCDRv2); - ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); - eprosima::fastcdr::serialize_key(ser, *p_type); - if (force_md5 || eprosima_test_StructType_max_key_cdr_typesize > 16) - { - md5_.init(); - md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); - md5_.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle.value[i] = md5_.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle.value[i] = key_buffer_[i]; - } - } - return true; - } - - void StructTypePubSubType::register_type_object_representation() - { - register_StructType_type_identifier(type_identifiers_); - } - - CompleteTestTypePubSubType::CompleteTestTypePubSubType() - { - set_name("eprosima::test::CompleteTestType"); - uint32_t type_size = eprosima_test_CompleteTestType_max_cdr_typesize; - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - max_serialized_type_size = type_size + 4; /*encapsulation*/ - is_compute_key_provided = false; - uint32_t key_length = eprosima_test_CompleteTestType_max_key_cdr_typesize > 16 ? eprosima_test_CompleteTestType_max_key_cdr_typesize : 16; - key_buffer_ = reinterpret_cast(malloc(key_length)); - memset(key_buffer_, 0, key_length); - } - - CompleteTestTypePubSubType::~CompleteTestTypePubSubType() - { - if (key_buffer_ != nullptr) - { - free(key_buffer_); - } - } - - bool CompleteTestTypePubSubType::serialize( - const void* const data, - SerializedPayload_t& payload, - DataRepresentationId_t data_representation) - { - const ::eprosima::test::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; - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - ser.set_dds_cdr_options({0,0}); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length - payload.length = static_cast(ser.get_serialized_data_length()); - return true; - } - - bool CompleteTestTypePubSubType::deserialize( - SerializedPayload_t& payload, - void* data) - { - try - { - // Convert DATA to pointer of your type - ::eprosima::test::CompleteTestType* p_type = static_cast<::eprosima::test::CompleteTestType*>(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); - - // 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; - } - - uint32_t CompleteTestTypePubSubType::calculate_serialized_size( - const void* const data, - DataRepresentationId_t data_representation) - { - 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; - } - } - - void* CompleteTestTypePubSubType::create_data() + } + else + { + for (uint8_t i = 0; i < 16; ++i) { - return reinterpret_cast(new ::eprosima::test::CompleteTestType()); + handle.value[i] = key_buffer[i]; } - - void CompleteTestTypePubSubType::delete_data( - void* data) - { - delete(reinterpret_cast<::eprosima::test::CompleteTestType*>(data)); - } - - bool CompleteTestTypePubSubType::compute_key( - SerializedPayload_t& payload, - InstanceHandle_t& handle, - bool force_md5) - { - if (!is_compute_key_provided) - { - return false; - } - - ::eprosima::test::CompleteTestType data; - if (deserialize(payload, static_cast(&data))) - { - return compute_key(static_cast(&data), handle, force_md5); - } - - return false; - } - - bool CompleteTestTypePubSubType::compute_key( - const void* const data, - InstanceHandle_t& handle, - bool force_md5) - { - if (!is_compute_key_provided) - { - return false; - } - - const ::eprosima::test::CompleteTestType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), - 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::XCDRv2); - ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); - eprosima::fastcdr::serialize_key(ser, *p_type); - if (force_md5 || eprosima_test_CompleteTestType_max_key_cdr_typesize > 16) - { - md5_.init(); - md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); - md5_.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle.value[i] = md5_.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle.value[i] = key_buffer_[i]; - } - } - return true; - } - - void CompleteTestTypePubSubType::register_type_object_representation() - { - register_CompleteTestType_type_identifier(type_identifiers_); - } - - KeyedCompleteTestTypePubSubType::KeyedCompleteTestTypePubSubType() - { - set_name("eprosima::test::KeyedCompleteTestType"); - uint32_t type_size = eprosima_test_KeyedCompleteTestType_max_cdr_typesize; - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - max_serialized_type_size = type_size + 4; /*encapsulation*/ - is_compute_key_provided = true; - uint32_t key_length = eprosima_test_KeyedCompleteTestType_max_key_cdr_typesize > 16 ? eprosima_test_KeyedCompleteTestType_max_key_cdr_typesize : 16; - key_buffer_ = reinterpret_cast(malloc(key_length)); - memset(key_buffer_, 0, key_length); - } - - KeyedCompleteTestTypePubSubType::~KeyedCompleteTestTypePubSubType() - { - if (key_buffer_ != nullptr) - { - free(key_buffer_); - } - } - - bool KeyedCompleteTestTypePubSubType::serialize( - const void* const data, - SerializedPayload_t& payload, - DataRepresentationId_t data_representation) - { - const ::eprosima::test::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; - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - ser.set_dds_cdr_options({0,0}); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length - payload.length = static_cast(ser.get_serialized_data_length()); - return true; - } - - bool KeyedCompleteTestTypePubSubType::deserialize( - SerializedPayload_t& payload, - void* data) - { - try - { - // Convert DATA to pointer of your type - ::eprosima::test::KeyedCompleteTestType* p_type = static_cast<::eprosima::test::KeyedCompleteTestType*>(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); - - // 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; - } - - uint32_t KeyedCompleteTestTypePubSubType::calculate_serialized_size( - const void* const data, - DataRepresentationId_t data_representation) - { - 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; - } - } - - void* KeyedCompleteTestTypePubSubType::create_data() - { - return reinterpret_cast(new ::eprosima::test::KeyedCompleteTestType()); - } - - void KeyedCompleteTestTypePubSubType::delete_data( - void* data) - { - delete(reinterpret_cast<::eprosima::test::KeyedCompleteTestType*>(data)); - } - - bool KeyedCompleteTestTypePubSubType::compute_key( - SerializedPayload_t& payload, - InstanceHandle_t& handle, - bool force_md5) - { - if (!is_compute_key_provided) - { - return false; - } - - ::eprosima::test::KeyedCompleteTestType data; - if (deserialize(payload, static_cast(&data))) - { - return compute_key(static_cast(&data), handle, force_md5); - } - - return false; - } - - bool KeyedCompleteTestTypePubSubType::compute_key( - const void* const data, - InstanceHandle_t& handle, - bool force_md5) - { - if (!is_compute_key_provided) - { - return false; - } - - const ::eprosima::test::KeyedCompleteTestType* p_type = static_cast(data); - - // 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::XCDRv2); - ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); - eprosima::fastcdr::serialize_key(ser, *p_type); - if (force_md5 || eprosima_test_KeyedCompleteTestType_max_key_cdr_typesize > 16) - { - md5_.init(); - md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); - md5_.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle.value[i] = md5_.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle.value[i] = key_buffer_[i]; - } - } - return true; - } - - void KeyedCompleteTestTypePubSubType::register_type_object_representation() - { - register_KeyedCompleteTestType_type_identifier(type_identifiers_); - } - - } // 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_; +} + +void KeyedCompleteTestTypePubSubType::register_type_object_representation() +{ + register_KeyedCompleteTestType_type_identifier(type_identifiers_); +} + +} // namespace test } // namespace eprosima diff --git a/fastdds_python/test/types/test_modulesPubSubTypes.hpp b/fastdds_python/test/types/test_modulesPubSubTypes.hpp index efd15120..e941fcaf 100644 --- a/fastdds_python/test/types/test_modulesPubSubTypes.hpp +++ b/fastdds_python/test/types/test_modulesPubSubTypes.hpp @@ -16,13 +16,15 @@ * @file test_modulesPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__EPROSIMA_TEST_TEST_MODULES_PUBSUBTYPES_HPP #define FAST_DDS_GENERATED__EPROSIMA_TEST_TEST_MODULES_PUBSUBTYPES_HPP +#include + #include #include #include @@ -37,258 +39,252 @@ Generated test_modules is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. #endif // FASTDDS_GEN_API_VER -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: +namespace eprosima { +namespace test { - typedef ::eprosima::test::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 ::eprosima::test::StructType type; - eProsima_user_DllExport ~StructTypePubSubType() override; + eProsima_user_DllExport StructTypePubSubType(); - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t& payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport ~StructTypePubSubType() override; - eProsima_user_DllExport bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t& payload, - void* data) override; + eProsima_user_DllExport bool serialize( + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport uint32_t calculate_serialized_size( - const void* const data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport bool deserialize( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + void* data) override; - eProsima_user_DllExport bool compute_key( - eprosima::fastdds::rtps::SerializedPayload_t& payload, - eprosima::fastdds::rtps::InstanceHandle_t& ihandle, - bool force_md5 = false) override; + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool compute_key( - const void* const data, - eprosima::fastdds::rtps::InstanceHandle_t& ihandle, - bool force_md5 = false) override; + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport void* create_data() override; + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport void delete_data( - void* data) override; + eProsima_user_DllExport void* create_data() override; - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() override; + eProsima_user_DllExport void delete_data( + void* data) override; - #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED - eProsima_user_DllExport inline bool is_bounded() const override - { - return false; - } + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() 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 +#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 - #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; + } - private: +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - eprosima::fastdds::MD5 md5_; - unsigned char* key_buffer_; +private: - }; +}; - /*! - * @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 ::eprosima::test::CompleteTestType type; + typedef ::eprosima::test::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( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t& payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport bool serialize( + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t& payload, - void* data) override; + eProsima_user_DllExport bool deserialize( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + void* data) override; - eProsima_user_DllExport uint32_t calculate_serialized_size( - const void* const data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool compute_key( - eprosima::fastdds::rtps::SerializedPayload_t& payload, - eprosima::fastdds::rtps::InstanceHandle_t& ihandle, - bool force_md5 = false) override; + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport bool compute_key( - const void* const data, - eprosima::fastdds::rtps::InstanceHandle_t& ihandle, - bool force_md5 = false) override; + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport void* create_data() override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void delete_data( - void* data) override; + eProsima_user_DllExport void delete_data( + void* data) override; - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() 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 +#ifdef 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; - } + 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: +private: - eprosima::fastdds::MD5 md5_; - unsigned char* key_buffer_; +}; - }; +/*! + * @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 ::eprosima::test::KeyedCompleteTestType type; - typedef ::eprosima::test::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( + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t& payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport bool deserialize( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + void* data) override; - eProsima_user_DllExport bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t& payload, - void* data) override; + eProsima_user_DllExport uint32_t calculate_serialized_size( + const void* const data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - eProsima_user_DllExport uint32_t calculate_serialized_size( - const void* const data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + eProsima_user_DllExport bool compute_key( + eprosima::fastdds::rtps::SerializedPayload_t& payload, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport bool compute_key( - eprosima::fastdds::rtps::SerializedPayload_t& payload, - eprosima::fastdds::rtps::InstanceHandle_t& ihandle, - bool force_md5 = false) override; + eProsima_user_DllExport bool compute_key( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t& ihandle, + bool force_md5 = false) override; - eProsima_user_DllExport bool compute_key( - const void* const data, - eprosima::fastdds::rtps::InstanceHandle_t& ihandle, - bool force_md5 = false) override; + eProsima_user_DllExport void* create_data() override; - eProsima_user_DllExport void* create_data() override; + eProsima_user_DllExport void delete_data( + void* data) override; - eProsima_user_DllExport void delete_data( - void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() 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 - #ifdef 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; + } - 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: - private: + unsigned char* key_buffer_ = nullptr; + std::mutex compute_key_mtx_; - eprosima::fastdds::MD5 md5_; - unsigned char* key_buffer_; + unsigned char* get_key_buffer_nts(); - }; +}; - } // namespace test -} // namespace eprosima +} // namespace test +} // namespace eprosima #endif // FAST_DDS_GENERATED__EPROSIMA_TEST_TEST_MODULES_PUBSUBTYPES_HPP diff --git a/fastdds_python/test/types/test_modulesPubSubTypes.i b/fastdds_python/test/types/test_modulesPubSubTypes.i index 62a34745..f217431a 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 (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ %import(module="fastdds") "fastdds/dds/topic/TopicDataType.hpp"; diff --git a/fastdds_python/test/types/test_modulesTypeObjectSupport.cxx b/fastdds_python/test/types/test_modulesTypeObjectSupport.cxx index a6de2110..c8101d19 100644 --- a/fastdds_python/test/types/test_modulesTypeObjectSupport.cxx +++ b/fastdds_python/test/types/test_modulesTypeObjectSupport.cxx @@ -16,7 +16,7 @@ * @file test_modulesTypeObjectSupport.cxx * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #include "test_modulesTypeObjectSupport.hpp" @@ -32,6 +32,7 @@ #include #include #include + #include "test_modules.hpp" diff --git a/fastdds_python/test/types/test_modulesTypeObjectSupport.hpp b/fastdds_python/test/types/test_modulesTypeObjectSupport.hpp index 1fadc768..0a1db9aa 100644 --- a/fastdds_python/test/types/test_modulesTypeObjectSupport.hpp +++ b/fastdds_python/test/types/test_modulesTypeObjectSupport.hpp @@ -16,7 +16,7 @@ * @file test_modulesTypeObjectSupport.hpp * Header file containing the API required to register the TypeObject representation of the described types in the IDL file * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__EPROSIMA_TEST_TEST_MODULES_TYPE_OBJECT_SUPPORT_HPP diff --git a/fastdds_python_examples/HelloWorldExample/generated_code/CMakeLists.txt b/fastdds_python_examples/HelloWorldExample/generated_code/CMakeLists.txt index 1e857efb..bb7228a2 100644 --- a/fastdds_python_examples/HelloWorldExample/generated_code/CMakeLists.txt +++ b/fastdds_python_examples/HelloWorldExample/generated_code/CMakeLists.txt @@ -116,7 +116,7 @@ target_link_libraries(${${PROJECT_NAME}_MODULE} ) # Find the installation path -execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))" +execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from sysconfig import get_path; print(get_path('purelib', vars={'base': '${CMAKE_INSTALL_PREFIX}'}))" OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE ) diff --git a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorld.hpp b/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorld.hpp index deaa6e71..c1bffdb4 100644 --- a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorld.hpp +++ b/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorld.hpp @@ -16,7 +16,7 @@ * @file HelloWorld.hpp * This header file contains the declaration of the described types in the IDL file. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__HELLOWORLD_HPP diff --git a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorld.i b/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorld.i index a0072643..46303c93 100644 --- a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorld.i +++ b/fastdds_python_examples/HelloWorldExample/generated_code/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 (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ %module(moduleimport="if __import__('os').name == 'nt': import win32api; win32api.LoadLibrary('HelloWorld.dll')\nif __package__ or '.' in __name__:\n from . import _HelloWorldWrapper\nelse:\n import _HelloWorldWrapper") HelloWorld @@ -120,6 +120,7 @@ namespace swig { // Include the class interfaces %include "HelloWorld.hpp" + // Include the corresponding TopicDataType %include "HelloWorldPubSubTypes.i" diff --git a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldCdrAux.hpp b/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldCdrAux.hpp index 3b2f62fd..d60861de 100644 --- a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldCdrAux.hpp +++ b/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldCdrAux.hpp @@ -16,13 +16,14 @@ * @file HelloWorldCdrAux.hpp * This source file contains some definitions of CDR related functions. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP #define FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP #include "HelloWorld.hpp" + constexpr uint32_t HelloWorld_max_cdr_typesize {268UL}; constexpr uint32_t HelloWorld_max_key_cdr_typesize {0UL}; diff --git a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldCdrAux.ipp b/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldCdrAux.ipp index 075f21ad..a8a908b9 100644 --- a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldCdrAux.ipp +++ b/fastdds_python_examples/HelloWorldExample/generated_code/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 (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP diff --git a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldPubSubTypes.cxx b/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldPubSubTypes.cxx index 664c12c6..8b647cb4 100644 --- a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldPubSubTypes.cxx +++ b/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldPubSubTypes.cxx @@ -16,11 +16,14 @@ * @file HelloWorldPubSubTypes.cpp * This header file contains the implementation of the serialization functions. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #include "HelloWorldPubSubTypes.hpp" +#include +#include + #include #include @@ -38,17 +41,10 @@ HelloWorldPubSubType::HelloWorldPubSubType() type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ max_serialized_type_size = type_size + 4; /*encapsulation*/ is_compute_key_provided = false; - uint32_t key_length = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - key_buffer_ = reinterpret_cast(malloc(key_length)); - memset(key_buffer_, 0, key_length); } HelloWorldPubSubType::~HelloWorldPubSubType() { - if (key_buffer_ != nullptr) - { - free(key_buffer_); - } } bool HelloWorldPubSubType::serialize( @@ -56,7 +52,8 @@ bool HelloWorldPubSubType::serialize( SerializedPayload_t& payload, DataRepresentationId_t data_representation) { - const ::HelloWorld* p_type = static_cast(data); + const ::HelloWorld* p_type = + static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.max_size); @@ -76,7 +73,7 @@ bool HelloWorldPubSubType::serialize( ser.serialize_encapsulation(); // Serialize the object. ser << *p_type; - ser.set_dds_cdr_options({0,0}); + ser.set_dds_cdr_options({0, 0}); } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -95,7 +92,8 @@ bool HelloWorldPubSubType::deserialize( try { // Convert DATA to pointer of your type - ::HelloWorld* p_type = static_cast<::HelloWorld*>(data); + ::HelloWorld* p_type = + static_cast<::HelloWorld*>(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload.data), payload.length); @@ -128,9 +126,10 @@ uint32_t HelloWorldPubSubType::calculate_serialized_size( 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*/; + const ::HelloWorld* p_type = + static_cast(data); + auto calc_size = calculator.calculate_serialized_size(*p_type, current_alignment); + return static_cast(calc_size) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -154,16 +153,9 @@ bool HelloWorldPubSubType::compute_key( InstanceHandle_t& handle, bool force_md5) { - if (!is_compute_key_provided) - { - return false; - } - - ::HelloWorld data; - if (deserialize(payload, static_cast(&data))) - { - return compute_key(static_cast(&data), handle, force_md5); - } + static_cast(payload); + static_cast(handle); + static_cast(force_md5); return false; } @@ -173,39 +165,11 @@ bool HelloWorldPubSubType::compute_key( InstanceHandle_t& handle, bool force_md5) { - if (!is_compute_key_provided) - { - return false; - } - - const ::HelloWorld* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(key_buffer_), - HelloWorld_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::XCDRv2); - ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); - eprosima::fastcdr::serialize_key(ser, *p_type); - if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) - { - md5_.init(); - md5_.update(key_buffer_, static_cast(ser.get_serialized_data_length())); - md5_.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle.value[i] = md5_.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle.value[i] = key_buffer_[i]; - } - } - return true; + return false; } void HelloWorldPubSubType::register_type_object_representation() diff --git a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldPubSubTypes.hpp b/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldPubSubTypes.hpp index a32c773f..f43052f3 100644 --- a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldPubSubTypes.hpp +++ b/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldPubSubTypes.hpp @@ -16,13 +16,15 @@ * @file HelloWorldPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP #define FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP +#include + #include #include #include @@ -114,9 +116,6 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType private: - eprosima::fastdds::MD5 md5_; - unsigned char* key_buffer_; - }; diff --git a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldPubSubTypes.i b/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldPubSubTypes.i index 586f31fe..b44b642f 100644 --- a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldPubSubTypes.i +++ b/fastdds_python_examples/HelloWorldExample/generated_code/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 (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ %import(module="fastdds") "fastdds/dds/topic/TopicDataType.hpp"; diff --git a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldTypeObjectSupport.cxx b/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldTypeObjectSupport.cxx index b9b20ce2..346ef07f 100644 --- a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldTypeObjectSupport.cxx +++ b/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldTypeObjectSupport.cxx @@ -16,7 +16,7 @@ * @file HelloWorldTypeObjectSupport.cxx * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #include "HelloWorldTypeObjectSupport.hpp" @@ -32,6 +32,7 @@ #include #include #include + #include "HelloWorld.hpp" diff --git a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldTypeObjectSupport.hpp b/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldTypeObjectSupport.hpp index 975c16c1..e2938540 100644 --- a/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldTypeObjectSupport.hpp +++ b/fastdds_python_examples/HelloWorldExample/generated_code/HelloWorldTypeObjectSupport.hpp @@ -16,7 +16,7 @@ * @file HelloWorldTypeObjectSupport.hpp * Header file containing the API required to register the TypeObject representation of the described types in the IDL file * - * This file was generated by the tool fastddsgen (version: 4.2.0). + * This file was generated by the tool fastddsgen (version: 4.3.0). */ #ifndef FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP